summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/for-of/syntax-1.js
blob: 7cc393ec12a1ebd8e149534b0a6f0169dcb46eec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// We correctly reject bogus for-of loop syntax.

load(libdir + "asserts.js");

function assertSyntaxError(code) {
    assertThrowsInstanceOf(function () { Function(code); }, SyntaxError, "Function:" + code);
    assertThrowsInstanceOf(function () { eval(code); }, SyntaxError, "eval:" + code);
    var ieval = eval;
    assertThrowsInstanceOf(function () { ieval(code); }, SyntaxError, "indirect eval:" + code);
}

function test(badForHead) {
    assertSyntaxError(badForHead + " {}");  // apply directly to forHead
    assertSyntaxError("[0 " + badForHead + "];");
}

var a, b, c;
test("for (a in b of c)");
test("for (a of b of c)");
test("for (let {a: 1} of b)");