diff options
Diffstat (limited to 'js/src/tests/non262/destructuring/constant-folding.js')
-rw-r--r-- | js/src/tests/non262/destructuring/constant-folding.js | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/js/src/tests/non262/destructuring/constant-folding.js b/js/src/tests/non262/destructuring/constant-folding.js new file mode 100644 index 0000000000..b5aa893215 --- /dev/null +++ b/js/src/tests/non262/destructuring/constant-folding.js @@ -0,0 +1,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); |