| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Flags: --harmony-async-await --allow-natives-syntax | 5 // Flags: --harmony-async-await --allow-natives-syntax |
| 6 | 6 |
| 7 // Do not install `AsyncFunction` constructor on global object | 7 // Do not install `AsyncFunction` constructor on global object |
| 8 | 8 |
| 9 function assertThrowsAsync(run, errorType, message) { | 9 function assertThrowsAsync(run, errorType, message) { |
| 10 var actual; | 10 var actual; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 | 63 |
| 64 assertTrue( | 64 assertTrue( |
| 65 hadValue, "Expected '" + run.toString() + "' to produce a value"); | 65 hadValue, "Expected '" + run.toString() + "' to produce a value"); |
| 66 | 66 |
| 67 assertEquals(expected, actual, msg); | 67 assertEquals(expected, actual, msg); |
| 68 }; | 68 }; |
| 69 | 69 |
| 70 assertEquals(undefined, this.AsyncFunction); | 70 assertEquals(undefined, this.AsyncFunction); |
| 71 let AsyncFunction = (async function() {}).constructor; | 71 let AsyncFunction = (async function() {}).constructor; |
| 72 | 72 |
| 73 // The AsyncFunction Constructor is the %AsyncFunction% intrinsic object and |
| 74 // is a subclass of Function. |
| 75 // (https://tc39.github.io/ecmascript-asyncawait/#async-function-constructor) |
| 76 assertEquals(Object.getPrototypeOf(AsyncFunction), Function); |
| 77 assertEquals(Object.getPrototypeOf(AsyncFunction.prototype), |
| 78 Function.prototype); |
| 79 assertTrue(async function() {} instanceof Function); |
| 80 |
| 81 |
| 73 // Let functionPrototype be the intrinsic object %AsyncFunctionPrototype%. | 82 // Let functionPrototype be the intrinsic object %AsyncFunctionPrototype%. |
| 74 async function asyncFunctionForProto() {} | 83 async function asyncFunctionForProto() {} |
| 75 assertEquals(AsyncFunction.prototype, | 84 assertEquals(AsyncFunction.prototype, |
| 76 Object.getPrototypeOf(asyncFunctionForProto)); | 85 Object.getPrototypeOf(asyncFunctionForProto)); |
| 77 assertEquals(AsyncFunction.prototype, | 86 assertEquals(AsyncFunction.prototype, |
| 78 Object.getPrototypeOf(async function() {})); | 87 Object.getPrototypeOf(async function() {})); |
| 79 assertEquals(AsyncFunction.prototype, Object.getPrototypeOf(async () => {})); | 88 assertEquals(AsyncFunction.prototype, Object.getPrototypeOf(async () => {})); |
| 80 assertEquals(AsyncFunction.prototype, | 89 assertEquals(AsyncFunction.prototype, |
| 81 Object.getPrototypeOf({ async method() {} }.method)); | 90 Object.getPrototypeOf({ async method() {} }.method)); |
| 82 assertEquals(AsyncFunction.prototype, Object.getPrototypeOf(AsyncFunction())); | 91 assertEquals(AsyncFunction.prototype, Object.getPrototypeOf(AsyncFunction())); |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 | 362 |
| 354 // Regress v8:5148 | 363 // Regress v8:5148 |
| 355 assertEqualsAsync("1", () => (async({ a = NaN }) => a)({ a: "1" })); | 364 assertEqualsAsync("1", () => (async({ a = NaN }) => a)({ a: "1" })); |
| 356 assertEqualsAsync( | 365 assertEqualsAsync( |
| 357 "10", () => (async(foo, { a = NaN }) => foo + a)("1", { a: "0" })); | 366 "10", () => (async(foo, { a = NaN }) => foo + a)("1", { a: "0" })); |
| 358 assertEqualsAsync("2", () => (async({ a = "2" }) => a)({ a: undefined })); | 367 assertEqualsAsync("2", () => (async({ a = "2" }) => a)({ a: undefined })); |
| 359 assertEqualsAsync( | 368 assertEqualsAsync( |
| 360 "20", () => (async(foo, { a = "0" }) => foo + a)("2", { a: undefined })); | 369 "20", () => (async(foo, { a = "0" }) => foo + a)("2", { a: undefined })); |
| 361 assertThrows(() => eval("async({ foo = 1 })"), SyntaxError); | 370 assertThrows(() => eval("async({ foo = 1 })"), SyntaxError); |
| 362 assertThrows(() => eval("async(a, { foo = 1 })"), SyntaxError); | 371 assertThrows(() => eval("async(a, { foo = 1 })"), SyntaxError); |
| OLD | NEW |