Bug 1185106 - Part 7.3: Add parser test for yield in async method. r=till
authorTooru Fujisawa <arai_a@mac.com>
Sun, 28 Aug 2016 23:58:29 +0900
changeset 320236 f43c3c900fd72163fb8083601c2719a5c0246ed4
parent 320235 3c623f1b1404e2627fd054f648d567b1c0b02ec6
child 320237 203903ea62ec88835f67ffaf938d39745461d486
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 7.3: Add parser test for yield in async method. r=till MozReview-Commit-ID: EkJSBtUFijk
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
@@ -2,43 +2,60 @@ 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);
 }
 
 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) {}");