js/src/jit-test/tests/for-of/syntax-1.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/jit-test/tests/for-of/syntax-1.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,22 @@
     1.4 +// We correctly reject bogus for-of loop syntax.
     1.5 +
     1.6 +load(libdir + "asserts.js");
     1.7 +
     1.8 +function assertSyntaxError(code) {
     1.9 +    assertThrowsInstanceOf(function () { Function(code); }, SyntaxError, "Function:" + code);
    1.10 +    assertThrowsInstanceOf(function () { eval(code); }, SyntaxError, "eval:" + code);
    1.11 +    var ieval = eval;
    1.12 +    assertThrowsInstanceOf(function () { ieval(code); }, SyntaxError, "indirect eval:" + code);
    1.13 +}
    1.14 +
    1.15 +function test(badForHead) {
    1.16 +    assertSyntaxError(badForHead + " {}");  // apply directly to forHead
    1.17 +    assertSyntaxError("[0 " + badForHead + "];");
    1.18 +}
    1.19 +
    1.20 +var a, b, c;
    1.21 +test("for (a in b of c)");
    1.22 +test("for each (a of b)");
    1.23 +test("for (a of b of c)");
    1.24 +test("for (let (a = 1) a of b)");
    1.25 +test("for (let {a: 1} of b)");

mercurial