Array destructuring tests to make sure compiler doesn't crash. Part of ES6 compatibility for Inline Type Aliases (full functionality + tests not yet complete).
@@ -272,4 +272,22 @@ public class InlineAliasesTest extends CompilerTestCase {
" }",
"}"));
}
+
+ public void testArrayDestructuringSwapDoesntCrash() {
+ testSame("var a = 1; var b = 3; [a, b] = [b, a];");
+ }
+
+ public void testArrayDestructuringVarAssignDoesntCrash() {
+ testSame("var foo = [1, 2, 3]; var [one, two, three] = foo;");
+ }
+
+ public void testArrayDestructuringFromFunctionDoesntCrash() {
+ testSame(
+ LINE_JOINER.join(
+ "function f() {",
+ " return [1, 2];",
+ "}",
+ "var a, b;",
+ "[a, b] = f();"));
+ }
}
