Debian Codegraph @

js/src/tests/test262/language/statements/for-await-of/async-from-sync-iterator-continuation-abrupt-completion-get-constructor.js

raw
1 // |reftest| async
2 // Copyright (C) 2019 André Bargull. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4
5 /*---
6 esid: sec-asyncfromsynciteratorcontinuation
7 description: >
8 Reject promise when PromiseResolve in AsyncFromSyncIteratorContinuation throws.
9 info: |
10 25.1.4.4 AsyncFromSyncIteratorContinuation ( result, promiseCapability )
11 ...
12 5. Let valueWrapper be PromiseResolve(%Promise%, « value »).
13 6. IfAbruptRejectPromise(valueWrapper, promiseCapability).
14 ...
15
16 includes: [compareArray.js]
17 flags: [async]
18 features: [async-iteration]
19 ---*/
20
21 var expected = [
22 "start",
23
24 // `valueWrapper` promise rejected.
25 "tick 1",
26
27 // `Await(nextResult)` in 13.7.5.13 done.
28 "tick 2",
29
30 // catch handler executed.
31 "catch",
32 ];
33
34 var actual = [];
35
36 async function f() {
37 var p = Promise.resolve(0);
38 Object.defineProperty(p, "constructor", {
39 get() {
40 throw new Error();
41 }
42 });
43 actual.push("start");
44 for await (var x of [p]);
45 actual.push("never reached");
46 }
47
48 Promise.resolve(0)
49 .then(() => actual.push("tick 1"))
50 .then(() => actual.push("tick 2"))
51 .then(() => {
52 assert.compareArray(actual, expected);
53 }).then($DONE, $DONE);
54
55 f().catch(() => actual.push("catch"));