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 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 } catch (e) { | 341 } catch (e) { |
342 log.push("resume:" + e); | 342 log.push("resume:" + e); |
343 } | 343 } |
344 return value + 1;`); | 344 return value + 1;`); |
345 log = []; | 345 log = []; |
346 assertEqualsAsync(6, () => resumeAfterThrowNewEval(5)); | 346 assertEqualsAsync(6, () => resumeAfterThrowNewEval(5)); |
347 assertEquals("start:5 resume:throw1 resume:throw2", log.join(" ")); | 347 assertEquals("start:5 resume:throw1 resume:throw2", log.join(" ")); |
348 | 348 |
349 async function foo() {} | 349 async function foo() {} |
350 assertEquals("async function foo() {}", foo.toString()); | 350 assertEquals("async function foo() {}", foo.toString()); |
351 assertEquals("async function () {}", async function() {}.toString()); | 351 assertEquals("async function () {}", async function () {}.toString()); |
352 assertEquals("async x => x", (async x => x).toString()); | 352 assertEquals("async x => x", (async x => x).toString()); |
353 assertEquals("async x => { return x }", (async x => { return x }).toString()); | 353 assertEquals("async x => { return x }", (async x => { return x }).toString()); |
354 class AsyncMethod { async foo() { } } | 354 class AsyncMethod { async foo() { } } |
355 assertEquals("async foo() { }", | 355 assertEquals("async foo() { }", |
356 Function.prototype.toString.call(AsyncMethod.prototype.foo)); | 356 Function.prototype.toString.call(AsyncMethod.prototype.foo)); |
357 assertEquals("async foo() { }", | 357 assertEquals("async foo() { }", |
358 Function.prototype.toString.call({async foo() { }}.foo)); | 358 Function.prototype.toString.call({async foo() { }}.foo)); |
359 | 359 |
360 // Async functions are not constructible | 360 // Async functions are not constructible |
361 assertThrows(() => class extends (async function() {}) {}, TypeError); | 361 assertThrows(() => class extends (async function() {}) {}, TypeError); |
362 | 362 |
363 // Regress v8:5148 | 363 // Regress v8:5148 |
364 assertEqualsAsync("1", () => (async({ a = NaN }) => a)({ a: "1" })); | 364 assertEqualsAsync("1", () => (async({ a = NaN }) => a)({ a: "1" })); |
365 assertEqualsAsync( | 365 assertEqualsAsync( |
366 "10", () => (async(foo, { a = NaN }) => foo + a)("1", { a: "0" })); | 366 "10", () => (async(foo, { a = NaN }) => foo + a)("1", { a: "0" })); |
367 assertEqualsAsync("2", () => (async({ a = "2" }) => a)({ a: undefined })); | 367 assertEqualsAsync("2", () => (async({ a = "2" }) => a)({ a: undefined })); |
368 assertEqualsAsync( | 368 assertEqualsAsync( |
369 "20", () => (async(foo, { a = "0" }) => foo + a)("2", { a: undefined })); | 369 "20", () => (async(foo, { a = "0" }) => foo + a)("2", { a: undefined })); |
370 assertThrows(() => eval("async({ foo = 1 })"), SyntaxError); | 370 assertThrows(() => eval("async({ foo = 1 })"), SyntaxError); |
371 assertThrows(() => eval("async(a, { foo = 1 })"), SyntaxError); | 371 assertThrows(() => eval("async(a, { foo = 1 })"), SyntaxError); |
OLD | NEW |