Bug 1185106 - Part 7.2: Add parser test for async method. r=efaust,till
authorMariusz Kierski <mkierski@mozilla.com>
Sun, 28 Aug 2016 23:58:29 +0900
changeset 346927 3c623f1b1404e2627fd054f648d567b1c0b02ec6
parent 346926 c6af45aef3045102fc696e52e468da0e55e3928b
child 346928 f43c3c900fd72163fb8083601c2719a5c0246ed4
push id10298
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:33:03 +0000
treeherdermozilla-aurora@7e29173b1641 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersefaust, till
bugs1185106
milestone52.0a1
Bug 1185106 - Part 7.2: Add parser test for async method. r=efaust,till MozReview-Commit-ID: Lv2sjpSILhz
js/src/jit-test/lib/syntax.js
js/src/tests/js1_8_5/reflect-parse/async.js
--- a/js/src/jit-test/lib/syntax.js
+++ b/js/src/jit-test/lib/syntax.js
@@ -1255,9 +1255,33 @@ function test_syntax(postfixes, check_er
   test("(async function (a) ");
   test("(async function (a) { ");
   test("(async function (a) {} ");
   test("(async function (a) { await ");
   test("(async function (a) { await X ");
   test("(async function (a) { await X; ");
   test("(async function (a) { await X; } ");
   test("(async function (a) { await X; }) ");
+
+  // async/await method
+
+  test("({ async ");
+  test("({ async m ");
+  test("({ async m( ");
+  test("({ async m() ");
+  test("({ async m() { ");
+  test("({ async m() {} ");
+  test("({ async m() {}, ");
+
+  test("class X { async ");
+  test("class X { async m ");
+  test("class X { async m( ");
+  test("class X { async m() ");
+  test("class X { async m() { ");
+  test("class X { async m() {} ");
+
+  test("class X { static async ");
+  test("class X { static async m ");
+  test("class X { static async m( ");
+  test("class X { static async m() ");
+  test("class X { static async m() { ");
+  test("class X { static async m() {} ");
 }
--- a/js/src/tests/js1_8_5/reflect-parse/async.js
+++ b/js/src/tests/js1_8_5/reflect-parse/async.js
@@ -2,13 +2,19 @@
 
 // async function declaration.
 assertDecl("async function foo() {}", asyncFunDecl(ident("foo"), [], blockStmt([])));
 
 // async function expression.
 assertExpr("(async function() {})", asyncFunExpr(null, [], blockStmt([])));
 assertExpr("(async function foo() {})", asyncFunExpr(ident("foo"), [], blockStmt([])));
 
+// async method.
+assertExpr("({ async foo() {} })", objExpr([{ key: ident("foo"), value: asyncFunExpr(ident("foo"), [], blockStmt([]))}]));
+
+assertStmt("class C { async foo() {} }", classStmt(ident("C"), null, [classMethod(ident("foo"), asyncFunExpr(ident("foo"), [], blockStmt([])), "method", false)]));
+assertStmt("class C { static async foo() {} }", classStmt(ident("C"), null, [classMethod(ident("foo"), asyncFunExpr(ident("foo"), [], blockStmt([])), "method", true)]));
+
 // await expression.
 assertDecl("async function foo() { await bar }", asyncFunDecl(ident("foo"), [], blockStmt([exprStmt(unExpr("await", ident("bar")))])));
 
 if (typeof reportCompare === 'function')
     reportCompare(true, true);