Skip to content

Commit

Permalink
Renaming tests for readability. Part of ES6 compatibility for Inline …
Browse files Browse the repository at this point in the history
…Type Aliases (full functionality + tests not yet complete).

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=158041095
  • Loading branch information
hjkaria authored and brad4d committed Jun 6, 2017
1 parent 42ceeff commit bef4e80
Showing 1 changed file with 44 additions and 7 deletions.
51 changes: 44 additions & 7 deletions test/com/google/javascript/jscomp/InlineAliasesTest.java
Expand Up @@ -273,15 +273,15 @@ public void testNoInlineAliasesInsideClassConstructor() {
"}")); "}"));
} }


public void testArrayDestructuringSwapDoesntCrash() { public void testArrayDestructuringSwap() {
testSame("var a = 1; var b = 3; [a, b] = [b, a];"); testSame("var a = 1; var b = 3; [a, b] = [b, a];");
} }


public void testArrayDestructuringVarAssignDoesntCrash() { public void testArrayDestructuringVarAssign() {
testSame("var foo = [1, 2, 3]; var [one, two, three] = foo;"); testSame("var foo = [1, 2, 3]; var [one, two, three] = foo;");
} }


public void testArrayDestructuringFromFunctionDoesntCrash() { public void testArrayDestructuringFromFunction() {
testSame( testSame(
LINE_JOINER.join( LINE_JOINER.join(
"function f() {", "function f() {",
Expand All @@ -291,19 +291,56 @@ public void testArrayDestructuringFromFunctionDoesntCrash() {
"[a, b] = f();")); "[a, b] = f();"));
} }


public void testObjectDestructuringBasicAssignDoesntCrash() { public void testObjectDestructuringBasicAssign() {
testSame("var o = {p: 42, q: true}; var {p, q} = o;"); testSame("var o = {p: 42, q: true}; var {p, q} = o;");
} }


public void testObjectDestructuringAssignWithoutDeclarationDoesntCrash() { public void testObjectDestructuringAssignWithoutDeclaration() {
testSame("var a, b; ({a, b} = {a: 1, b: 2});"); testSame("var a, b; ({a, b} = {a: 1, b: 2});");
} }


public void testObjectDestructuringAssignNewVarNamesDoesntCrash() { public void testObjectDestructuringAssignNewVarNames() {
testSame("var o = {p: 42, q: true}; var {p: foo, q: bar} = o;"); testSame("var o = {p: 42, q: true}; var {p: foo, q: bar} = o;");
} }


public void testObjectDestructuringDefaultValsDoesntCrash() { public void testObjectDestructuringDefaultVals() {
testSame("var {a = 10, b = 5} = {a: 3};"); testSame("var {a = 10, b = 5} = {a: 3};");
} }

public void testArrayDestructuringWithParameter() {
testSame(
LINE_JOINER.join(
"function f([name, val]) {",
" console.log(name, val);",
"}",
"f(['bar', 42]);"));
}

public void testObjectDestructuringWithParameters() {
testSame(
LINE_JOINER.join(
"function g({",
" name: n,",
" val: v",
"}) {",
" console.log(n, v);",
"}",
"g({",
" name: 'foo',",
" val: 7",
"});"));
}

public void testObjectDestructuringWithParametersAndStyleShortcut() {
testSame(
LINE_JOINER.join(
"function h({",
" name,",
" val",
"}) {",
" console.log(name, val);",
"}",
"f({name: 'bar', val: 42});"));
}

} }

0 comments on commit bef4e80

Please sign in to comment.