diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/non262/statements/for-in-with-destructuring-assignments.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | js/src/tests/non262/statements/for-in-with-destructuring-assignments.js | 130 |
1 files changed, 130 insertions, 0 deletions
diff --git a/js/src/tests/non262/statements/for-in-with-destructuring-assignments.js b/js/src/tests/non262/statements/for-in-with-destructuring-assignments.js new file mode 100644 index 0000000000..6741c885e5 --- /dev/null +++ b/js/src/tests/non262/statements/for-in-with-destructuring-assignments.js @@ -0,0 +1,130 @@ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ + +var gTestfile = "for-in-with-destructuring-assignments.js"; +var BUGNUMBER = 1164741; +var summary = "|for (var <pat> = ... in ...)| is invalid syntax"; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +// This is a total grab-bag of junk originally in tests changed when this +// syntax was removed. Avert your eyes! + +assertThrowsInstanceOf(() => eval(` + for (var [x] = x>>x in [[]<[]]) + { + []; + }`), + SyntaxError); + +/******************************************************************************/ + +assertThrowsInstanceOf(function() { + // Abandon all hope, ye who try to read this. + eval(` + (function () { + for + (var [x] = function(){} + in + (function m(a) { + if (a < 1) { + x; + return; + } + return m(a - 1) + m(a - 2); + })(7)(eval("")) + ) + { + []; + } + }) + `)(); +}, SyntaxError); + +/******************************************************************************/ + +assertThrowsInstanceOf(() => eval(` + for (var [e] = [] in (eval("for (b = 0; b < 6; ++b) gc()"))) {} +`), SyntaxError); + +/******************************************************************************/ + +assertThrowsInstanceOf(() => eval("for (var [ v , c ] = 0 in undefined) { }"), + SyntaxError); + +/******************************************************************************/ + +assertThrowsInstanceOf(() => eval("var b = e; for (var [e] = b in w) c"), + SyntaxError); + +/******************************************************************************/ + +assertThrowsInstanceOf(() => eval("for (var {a: []} = 2 in []) { }"), + SyntaxError); + +/******************************************************************************/ + +assertThrowsInstanceOf(() => eval(`try + { + for (var [,{y}] = 1 in []) {} + } + catch(ex) + { + }`), +SyntaxError); + +/******************************************************************************/ + +assertThrowsInstanceOf(() => eval("for (var [x] = [] in null);"), + SyntaxError); + +/******************************************************************************/ + +assertThrowsInstanceOf(() => eval("for (var [x] = x in y) var x;"), + SyntaxError); + +/******************************************************************************/ + +assertThrowsInstanceOf(() => eval(` + for (var [arguments] = ({ get y(){} }) in y ) (x); +`), +SyntaxError); + +/******************************************************************************/ + +if (typeof evalcx == 'function') { + var src = 'try {\n' + + ' for (var [e] = /x/ in d) {\n' + + ' (function () {});\n' + + ' }\n' + + '} catch (e) {}\n' + + 'try {\n' + + ' let(x = Object.freeze(this, /x/))\n' + + ' e = {}.toString\n' + + ' function y() {}\n' + + '} catch (e) {}'; + + try + { + evalcx(src); + throw new Error("didn't throw"); + } + catch (e) + { + assertEq(e.name === "SyntaxError", true, + "expected invalid syntax, got " + e); + } +} + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete"); |