summaryrefslogtreecommitdiffstats
path: root/js/src/tests/ecma_6/Comprehensions/for-reserved-word.js
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@wolfbeast.com>2019-08-23 01:43:12 +0200
committerwolfbeast <mcwerewolf@wolfbeast.com>2019-08-23 01:43:12 +0200
commitdd33cb382321351aa3b960a6824cb9ec43bba05b (patch)
tree729b4065b2a1c849d1fb6ad28b7e0c510f1a6a67 /js/src/tests/ecma_6/Comprehensions/for-reserved-word.js
parent6a6e4bd25d61ecf21a28ea47f2a74927553fe959 (diff)
parentab6242a93b849b0a3c7525b16bc01dd3172fc167 (diff)
downloadUXP-dd33cb382321351aa3b960a6824cb9ec43bba05b.tar
UXP-dd33cb382321351aa3b960a6824cb9ec43bba05b.tar.gz
UXP-dd33cb382321351aa3b960a6824cb9ec43bba05b.tar.lz
UXP-dd33cb382321351aa3b960a6824cb9ec43bba05b.tar.xz
UXP-dd33cb382321351aa3b960a6824cb9ec43bba05b.zip
Merge branch 'master' into Pale_Moon-release
Diffstat (limited to 'js/src/tests/ecma_6/Comprehensions/for-reserved-word.js')
-rw-r--r--js/src/tests/ecma_6/Comprehensions/for-reserved-word.js107
1 files changed, 107 insertions, 0 deletions
diff --git a/js/src/tests/ecma_6/Comprehensions/for-reserved-word.js b/js/src/tests/ecma_6/Comprehensions/for-reserved-word.js
new file mode 100644
index 000000000..9b320fc91
--- /dev/null
+++ b/js/src/tests/ecma_6/Comprehensions/for-reserved-word.js
@@ -0,0 +1,107 @@
+var BUGNUMBER = 1340089;
+var summary = "Comprehension should check the binding names";
+
+print(BUGNUMBER + ": " + summary);
+
+// Non strict mode.
+// Keywords, literals, 'let', and 'yield' are not allowed.
+
+assertThrowsInstanceOf(function () {
+ eval("[for (true of [1]) 2]");
+}, SyntaxError);
+assertThrowsInstanceOf(function () {
+ eval("(for (true of [1]) 2)");
+}, SyntaxError);
+
+assertThrowsInstanceOf(function () {
+ eval("[for (throw of [1]) 2]");
+}, SyntaxError);
+assertThrowsInstanceOf(function () {
+ eval("(for (throw of [1]) 2)");
+}, SyntaxError);
+
+assertThrowsInstanceOf(function () {
+ eval("[for (let of [1]) 2]");
+}, SyntaxError);
+assertThrowsInstanceOf(function () {
+ eval("(for (let of [1]) 2)");
+}, SyntaxError);
+
+assertThrowsInstanceOf(function () {
+ eval("[for (yield of [1]) 2]");
+}, SyntaxError);
+assertThrowsInstanceOf(function () {
+ eval("(for (yield of [1]) 2)");
+}, SyntaxError);
+
+eval("[for (public of [1]) 2]");
+eval("(for (public of [1]) 2)");
+
+eval("[for (static of [1]) 2]");
+eval("(for (static of [1]) 2)");
+
+// Strict mode.
+// All reserved words are not allowed.
+
+assertThrowsInstanceOf(function () {
+ "use strict";
+ eval("[for (true of [1]) 2]");
+}, SyntaxError);
+assertThrowsInstanceOf(function () {
+ "use strict";
+ eval("(for (true of [1]) 2)");
+}, SyntaxError);
+
+assertThrowsInstanceOf(function () {
+ "use strict";
+ eval("[for (throw of [1]) 2]");
+}, SyntaxError);
+assertThrowsInstanceOf(function () {
+ "use strict";
+ eval("(for (throw of [1]) 2)");
+}, SyntaxError);
+
+assertThrowsInstanceOf(function () {
+ "use strict";
+ eval("[for (let of [1]) 2]");
+}, SyntaxError);
+assertThrowsInstanceOf(function () {
+ "use strict";
+ eval("(for (let of [1]) 2)");
+}, SyntaxError);
+
+assertThrowsInstanceOf(function () {
+ "use strict";
+ eval("[for (yield of [1]) 2]");
+}, SyntaxError);
+assertThrowsInstanceOf(function () {
+ "use strict";
+ eval("(for (yield of [1]) 2)");
+}, SyntaxError);
+
+assertThrowsInstanceOf(function () {
+ "use strict";
+ eval("[for (public of [1]) 2]");
+}, SyntaxError);
+assertThrowsInstanceOf(function () {
+ "use strict";
+ eval("(for (public of [1]) 2)");
+}, SyntaxError);
+
+assertThrowsInstanceOf(function () {
+ "use strict";
+ eval("[for (static of [1]) 2]");
+}, SyntaxError);
+assertThrowsInstanceOf(function () {
+ "use strict";
+ eval("(for (static of [1]) 2)");
+}, SyntaxError);
+
+(function () {
+ "use strict";
+ eval("[for (await of [1]) 2]");
+ eval("(for (await of [1]) 2)");
+})();
+
+if (typeof reportCompare === "function")
+ reportCompare(true, true);