Bug 1185106 - Part 7.2: Add parser test for async method. r=efaust,till
MozReview-Commit-ID: Lv2sjpSILhz
--- 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);