summaryrefslogtreecommitdiff
path: root/js/src/tests
diff options
context:
space:
mode:
authorGaming4JC <g4jc@hyperbola.info>2019-06-09 17:20:09 -0400
committerGaming4JC <g4jc@hyperbola.info>2019-07-18 22:38:37 -0400
commit56108964ea0dac0fec99d659fbaf623f63dad805 (patch)
tree92709b6e1c70d7e4594c68d9f73ae297d6f6dc67 /js/src/tests
parent9fb05a4d65573ce336e09b82c70f833ea7f314e1 (diff)
downloaduxp-56108964ea0dac0fec99d659fbaf623f63dad805.tar.gz
1340089 - Check the binding name in comprehensionFor.
Diffstat (limited to 'js/src/tests')
-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 0000000000..9b320fc91e
--- /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);