summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/destructuring/constant-folding.js
blob: b5aa893215a0698b33f7ac2ec6cc6e6aff628780 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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);
}

// |true && a| is constant-folded to |a|, ensure the destructuring assignment
// validation takes place before constant-folding.
for (let prefix of ["null,", "var", "let", "const"]) {
    assertSyntaxError(`${prefix} [true && a] = [];`);
    assertSyntaxError(`${prefix} {p: true && a} = {};`);
}

if (typeof reportCompare === "function")
    reportCompare(true, true);