Bug 1185106 - Part 6.3: Add parser test for yield in async function expression. r=till
authorTooru Fujisawa <arai_a@mac.com>
Sun, 28 Aug 2016 23:58:28 +0900
changeset 320233 1a245de062189dcefd7488ac740c66d30e5e2a65
parent 320232 d19d9f409b751a282f60b9c5d0a0a284004b6fb4
child 320234 c6af45aef3045102fc696e52e468da0e55e3928b
push id20754
push usercbook@mozilla.com
push dateMon, 31 Oct 2016 15:58:35 +0000
treeherderfx-team@b1b66b1780c2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstill
bugs1185106
milestone52.0a1
Bug 1185106 - Part 6.3: Add parser test for yield in async function expression. r=till MozReview-Commit-ID: CovUsWjP1ER
js/src/tests/ecma_7/AsyncFunctions/yield.js
--- a/js/src/tests/ecma_7/AsyncFunctions/yield.js
+++ b/js/src/tests/ecma_7/AsyncFunctions/yield.js
@@ -1,33 +1,44 @@
 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})`);
 }
 
 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);
 }
 
 function testErrorArgsBodyStrict(argsbody) {
     testErrorArgsBody(argsbody);
     testErrorArgsBody(argsbody, "'use strict'; ");
 }
 
 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` 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) {}");