Debian Codegraph @

js/src/tests/test262/language/statements/async-generator/yield-star-next-then-non-callable-string-fulfillpromise.js

raw
1 // |reftest| async
2 // This file was procedurally generated from the following sources:
3 // - src/async-generators/yield-star-next-then-non-callable-string-fulfillpromise.case
4 // - src/async-generators/default/async-declaration.template
5 /*---
6 description: FulfillPromise if next().then is not-callable (string) (Async generator Function declaration)
7 esid: prod-AsyncGeneratorDeclaration
8 features: [Symbol.iterator, Symbol.asyncIterator, async-iteration]
9 flags: [generated, async]
10 info: |
11 Async Generator Function Definitions
12
13 AsyncGeneratorDeclaration:
14 async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) {
15 AsyncGeneratorBody }
16
17
18 YieldExpression: yield * AssignmentExpression
19 ...
20 6. Repeat
21 a. If received.[[Type]] is normal, then
22 ii. Let innerResult be ? Invoke(iterator, "next",
23 « received.[[Value]] »).
24 iii. If generatorKind is async, then set innerResult to
25 ? Await(innerResult).
26 iv. If Type(innerResult) is not Object, throw a TypeError exception.
27 ...
28
29 Await
30
31 ...
32 2. Let promiseCapability be ! NewPromiseCapability(%Promise%).
33 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »).
34 ...
35
36 Promise Resolve Functions
37
38 ...
39 7. If Type(resolution) is not Object, then
40 a. Return FulfillPromise(promise, resolution).
41 8. Let then be Get(resolution, "then").
42 ...
43 11. If IsCallable(thenAction) is false, then
44 a. Return FulfillPromise(promise, resolution).
45 ...
46
47 ---*/
48 var obj = {
49 get [Symbol.iterator]() {
50 throw new Test262Error('it should not get Symbol.iterator');
51 },
52 [Symbol.asyncIterator]() {
53 return {
54 next() {
55 return {
56 then: '',
57 value: 42,
58 done: false
59 }
60 }
61 };
62 }
63 };
64
65
66
67 var callCount = 0;
68
69 async function *gen() {
70 callCount += 1;
71 yield* obj;
72 throw new Test262Error('completion closes iter');
73
74 }
75
76 var iter = gen();
77
78 iter.next().then(({ value, done }) => {
79 assert.sameValue(value, 42);
80 assert.sameValue(done, false);
81 }).then($DONE, $DONE);
82
83 assert.sameValue(callCount, 1);