Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/language/expressions/class/async-gen-method-static-yield-star-next-then-non-callable-null-fulfillpromise.js

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