Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/language/expressions/class/async-gen-method-static-yield-star-getiter-async-null-sync-get-abrupt.js

raw
1 // This file was procedurally generated from the following sources:
2 // - src/async-generators/yield-star-getiter-async-null-sync-get-abrupt.case
3 // - src/async-generators/default/async-class-expr-static-method.template
4 /*---
5 description: Abrupt completion while getting @@iterator after null @@asyncIterator (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 1. Let exprRef be the result of evaluating AssignmentExpression.
25 2. Let value be ? GetValue(exprRef).
26 3. Let generatorKind be ! GetGeneratorKind().
27 4. Let iterator be ? GetIterator(value, generatorKind).
28 ...
29
30 GetIterator ( obj [ , hint ] )
31
32 ...
33 3. If hint is async,
34 a. Set method to ? GetMethod(obj, @@asyncIterator).
35 b. If method is undefined,
36 i. Let syncMethod be ? GetMethod(obj, @@iterator).
37 ...
38
39 GetMethod ( V, P )
40
41 ...
42 2. Let func be ? GetV(V, P).
43 ...
44
45 ---*/
46 var calls = 0;
47 var reason = {};
48 var obj = {
49 get [Symbol.iterator]() {
50 throw reason;
51 },
52 get [Symbol.asyncIterator]() {
53 calls += 1;
54 return null;
55 }
56 };
57
58
59
60 var callCount = 0;
61
62 var C = class { static async *gen() {
63 callCount += 1;
64 yield* obj;
65 throw new Test262Error('abrupt completion closes iter');
66
67 }}
68
69 var gen = C.gen;
70
71 var iter = gen();
72
73 iter.next().then(() => {
74 throw new Test262Error('Promise incorrectly fulfilled.');
75 }, v => {
76 assert.sameValue(v, reason, 'reject reason');
77 assert.sameValue(calls, 1);
78
79 iter.next().then(({ done, value }) => {
80 assert.sameValue(done, true, 'the iterator is completed');
81 assert.sameValue(value, undefined, 'value is undefined');
82 }).then($DONE, $DONE);
83 }).catch($DONE);
84
85 assert.sameValue(callCount, 1);