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 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
336 log = []; | 336 log = []; |
337 assertEqualsAsync(6, () => resumeAfterThrowNewEval(5)); | 337 assertEqualsAsync(6, () => resumeAfterThrowNewEval(5)); |
338 assertEquals("start:5 resume:throw1 resume:throw2", log.join(" ")); | 338 assertEquals("start:5 resume:throw1 resume:throw2", log.join(" ")); |
339 | 339 |
340 async function foo() {} | 340 async function foo() {} |
341 assertEquals("async function foo() {}", foo.toString()); | 341 assertEquals("async function foo() {}", foo.toString()); |
342 assertEquals("async function () {}", async function() {}.toString()); | 342 assertEquals("async function () {}", async function() {}.toString()); |
343 assertEquals("async x => x", (async x => x).toString()); | 343 assertEquals("async x => x", (async x => x).toString()); |
344 assertEquals("async x => { return x }", (async x => { return x }).toString()); | 344 assertEquals("async x => { return x }", (async x => { return x }).toString()); |
345 class AsyncMethod { async foo() { } } | 345 class AsyncMethod { async foo() { } } |
346 assertEquals("async foo() { }", Function.prototype.toString.call(AsyncMethod.pro totype.foo)); | 346 assertEquals("async foo() { }", |
347 assertEquals("async foo() { }", Function.prototype.toString.call({async foo() { }}.foo)); | 347 Function.prototype.toString.call(AsyncMethod.prototype.foo)); |
348 assertEquals("async foo() { }", | |
349 Function.prototype.toString.call({async foo() { }}.foo)); | |
348 | 350 |
349 // Async functions are not constructible | 351 // Async functions are not constructible |
350 assertThrows(() => class extends (async function() {}) {}, TypeError); | 352 assertThrows(() => class extends (async function() {}) {}, TypeError); |
353 | |
354 // Regress v8:5148 | |
355 assertEqualsAsync("1", () => (async({ a = NaN }) => a)({ a: "1" })); | |
356 assertEqualsAsync("10", | |
357 () => (async(foo, { a = NaN }) => foo + a)("1", { a: "0" })); | |
Dan Ehrenberg
2016/06/24 17:30:41
If you're writing tests for defaults, maybe let a:
caitp (gmail)
2016/06/24 18:05:40
Done
| |
358 assertThrows(() => eval("async({ foo = 1 })"), SyntaxError); | |
359 assertThrows(() => eval("async(a, { foo = 1 })"), SyntaxError); | |
OLD | NEW |