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