summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/for-of/syntax-4.js
blob: a6c3214840336039588213241bb33fbb45df48fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// The right-hand-side of a for-of is an assignment expression.

load(libdir + 'asserts.js');

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

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

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

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