summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/for-of/syntax-3.js
blob: 01b7cce1c111105de35c5012a47ea340f1fa4920 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// For-of can't have initializers.

load(libdir + 'asserts.js');

function assertSyntaxError(str) {
  assertThrowsInstanceOf(function () { return Function(str); }, SyntaxError);
}

assertSyntaxError("for (var x = 1 of []) {}");
assertSyntaxError("for (var [x] = 1 of []) {}");
assertSyntaxError("for (var {x} = 1 of []) {}");

assertSyntaxError("for (let x = 1 of []) {}");
assertSyntaxError("for (let [x] = 1 of []) {}");
assertSyntaxError("for (let {x} = 1 of []) {}");

assertSyntaxError("for (const x = 1 of []) {}");
assertSyntaxError("for (const [x] = 1 of []) {}");
assertSyntaxError("for (const {x} = 1 of []) {}");