summaryrefslogtreecommitdiffstats
path: root/js/src/tests/ecma_7/AsyncFunctions/yield.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /js/src/tests/ecma_7/AsyncFunctions/yield.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'js/src/tests/ecma_7/AsyncFunctions/yield.js')
-rw-r--r--js/src/tests/ecma_7/AsyncFunctions/yield.js71
1 files changed, 71 insertions, 0 deletions
diff --git a/js/src/tests/ecma_7/AsyncFunctions/yield.js b/js/src/tests/ecma_7/AsyncFunctions/yield.js
new file mode 100644
index 000000000..348d11f3d
--- /dev/null
+++ b/js/src/tests/ecma_7/AsyncFunctions/yield.js
@@ -0,0 +1,71 @@
+var BUGNUMBER = 1185106;
+var summary = "yield handling in async function";
+
+print(BUGNUMBER + ": " + summary);
+
+function testPassArgsBody(argsbody) {
+ Reflect.parse(`async function a${argsbody}`);
+ Reflect.parse(`(async function a${argsbody})`);
+ Reflect.parse(`(async function ${argsbody})`);
+ Reflect.parse(`({ async m${argsbody} })`);
+}
+
+function testErrorArgsBody(argsbody, prefix="") {
+ assertThrows(() => Reflect.parse(`${prefix} async function a${argsbody}`), SyntaxError);
+ assertThrows(() => Reflect.parse(`${prefix} (async function a${argsbody})`), SyntaxError);
+ assertThrows(() => Reflect.parse(`${prefix} (async function ${argsbody})`), SyntaxError);
+ assertThrows(() => Reflect.parse(`${prefix} ({ async m${argsbody} })`), SyntaxError);
+}
+
+function testErrorArgsBodyStrict(argsbody) {
+ testErrorArgsBody(argsbody);
+ testErrorArgsBody(argsbody, "'use strict'; ");
+ assertThrows(() => Reflect.parse(`class X { async m${argsbody} }`), SyntaxError);
+ assertThrows(() => Reflect.parse(`class X { static async m${argsbody} }`), SyntaxError);
+ assertThrows(() => Reflect.parse(`export default async function ${argsbody}`, { target: "module" }), SyntaxError);
+}
+
+if (typeof Reflect !== "undefined" && Reflect.parse) {
+ // `yield` handling is inherited in async function declaration name.
+ Reflect.parse("async function yield() {}");
+ Reflect.parse("function f() { async function yield() {} }");
+ assertThrows(() => Reflect.parse("function* g() { async function yield() {} }"), SyntaxError);
+ assertThrows(() => Reflect.parse("'use strict'; async function yield() {}"), SyntaxError);
+
+ // `yield` is treated as an identifier in an async function expression name.
+ // `yield` is not allowed as an identifier in strict code.
+ Reflect.parse("(async function yield() {});");
+ Reflect.parse("function f() { (async function yield() {}); }");
+ Reflect.parse("function* g() { (async function yield() {}); }");
+ assertThrows(() => Reflect.parse("'use strict'; (async function yield() {});"), SyntaxError);
+
+ // `yield` handling is inherited in async method name.
+ Reflect.parse("({ async yield() {} });");
+ Reflect.parse("function f() { ({ async yield() {} }); }");
+ Reflect.parse("function* g() { ({ async yield() {} }); }");
+ Reflect.parse("'use strict'; ({ async yield() {} });");
+ Reflect.parse("class X { async yield() {} }");
+
+ Reflect.parse("({ async [yield]() {} });");
+ Reflect.parse("function f() { ({ async [yield]() {} }); }");
+ Reflect.parse("function* g() { ({ async [yield]() {} }); }");
+ assertThrows(() => Reflect.parse("'use strict'; ({ async [yield]() {} });"), SyntaxError);
+ assertThrows(() => Reflect.parse("class X { async [yield]() {} }"), SyntaxError);
+
+ // `yield` is treated as an identifier in an async function parameter
+ // `yield` is not allowed as an identifier in strict code.
+ testPassArgsBody("(yield) {}");
+ testPassArgsBody("(yield = 1) {}");
+ testPassArgsBody("(a = yield) {}");
+ testErrorArgsBodyStrict("(yield 3) {}");
+ testErrorArgsBodyStrict("(a = yield 3) {}");
+
+ // `yield` is treated as an identifier in an async function body
+ // `yield` is not allowed as an identifier in strict code.
+ testPassArgsBody("() { yield; }");
+ testPassArgsBody("() { yield = 1; }");
+ testErrorArgsBodyStrict("() { yield 3; }");
+}
+
+if (typeof reportCompare === "function")
+ reportCompare(true, true);