async.js (1370B)
1 // |reftest| skip-if(!xulRuntime.shell) 2 3 // async function declaration. 4 assertDecl("async function foo() {}", asyncFunDecl(ident("foo"), [], blockStmt([]))); 5 6 // async function expression. 7 assertExpr("(async function() {})", asyncFunExpr(null, [], blockStmt([]))); 8 assertExpr("(async function foo() {})", asyncFunExpr(ident("foo"), [], blockStmt([]))); 9 10 // async arrow. 11 assertExpr("async a => 1", asyncArrowExpr(true, [ident("a")], literal(1))); 12 assertExpr("async a => { 1 }", asyncArrowExpr(false, [ident("a")], blockStmt([exprStmt(literal(1))]))); 13 assertExpr("async a => { return 1 }", asyncArrowExpr(false, [ident("a")], blockStmt([returnStmt(literal(1))]))); 14 15 // async method. 16 assertExpr("({ async foo() {} })", objExpr([{ key: ident("foo"), value: asyncFunExpr(ident("foo"), [], blockStmt([]))}])); 17 18 assertStmt("class C { async foo() {} }", classStmt(ident("C"), null, [classMethod(ident("foo"), asyncFunExpr(ident("foo"), [], blockStmt([])), "method", false)])); 19 assertStmt("class C { static async foo() {} }", classStmt(ident("C"), null, [classMethod(ident("foo"), asyncFunExpr(ident("foo"), [], blockStmt([])), "method", true)])); 20 21 // await expression. 22 assertDecl("async function foo() { await bar }", asyncFunDecl(ident("foo"), [], blockStmt([exprStmt(unExpr("await", ident("bar")))]))); 23 24 if (typeof reportCompare === 'function') 25 reportCompare(true, true);