blob: ddcf50f3f050b85e8f171dcef976976b8087f9c7 [file] [log] [blame]
caitp@igalia.com8bc562d2016-11-14 21:14:15 +00001function shouldBe(actual, expected) {
2 if (actual !== expected)
3 throw new Error('bad value: ' + actual);
4}
5
6var AsyncFunctionPrototype = async function() {}.__proto__;
7
8function testAsyncFunctionExpression()
9{
10 return async function()
11 {
12 await 42;
13 return 1;
14 };
15}
16noInline(testAsyncFunctionExpression);
17
18function testAsyncFunctionDeclaration()
19{
20 async function asyncFn()
21 {
22 await 42;
23 return 1;
24 }
25
26 return asyncFn;
27}
28noInline(testAsyncFunctionDeclaration);
29
30function testAsyncArrowFunction()
31{
32 return async() =>
33 {
34 await 42;
35 return 1;
36 };
37}
38noInline(testAsyncArrowFunction);
39
40for (var i = 0; i < 1e4; ++i) {
41 shouldBe(testAsyncFunctionExpression().__proto__, AsyncFunctionPrototype);
42 shouldBe(testAsyncFunctionDeclaration().__proto__, AsyncFunctionPrototype);
43 shouldBe(testAsyncArrowFunction().__proto__, AsyncFunctionPrototype);
44}