michael@0: // We correctly reject bogus for-of loop syntax. michael@0: michael@0: load(libdir + "asserts.js"); michael@0: michael@0: function assertSyntaxError(code) { michael@0: assertThrowsInstanceOf(function () { Function(code); }, SyntaxError, "Function:" + code); michael@0: assertThrowsInstanceOf(function () { eval(code); }, SyntaxError, "eval:" + code); michael@0: var ieval = eval; michael@0: assertThrowsInstanceOf(function () { ieval(code); }, SyntaxError, "indirect eval:" + code); michael@0: } michael@0: michael@0: function test(badForHead) { michael@0: assertSyntaxError(badForHead + " {}"); // apply directly to forHead michael@0: assertSyntaxError("[0 " + badForHead + "];"); michael@0: } michael@0: michael@0: var a, b, c; michael@0: test("for (a in b of c)"); michael@0: test("for each (a of b)"); michael@0: test("for (a of b of c)"); michael@0: test("for (let (a = 1) a of b)"); michael@0: test("for (let {a: 1} of b)");