Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/language/expressions/async-generator/yield-star-next-then-non-callable-string-fulfillpromise.js

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