Debian Codegraph @

js/src/tests/test262/language/expressions/class/async-gen-method/yield-star-getiter-async-null-sync-get-abrupt.js

raw
1 // |reftest| async
2 // This file was procedurally generated from the following sources:
3 // - src/async-generators/yield-star-getiter-async-null-sync-get-abrupt.case
4 // - src/async-generators/default/async-class-expr-method.template
5 /*---
6 description: Abrupt completion while getting @@iterator after null @@asyncIterator (Async generator method as a ClassExpression element)
7 esid: prod-AsyncGeneratorMethod
8 features: [Symbol.iterator, Symbol.asyncIterator, async-iteration]
9 flags: [generated, async]
10 info: |
11 ClassElement :
12 MethodDefinition
13
14 MethodDefinition :
15 AsyncGeneratorMethod
16
17 Async Generator Function Definitions
18
19 AsyncGeneratorMethod :
20 async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody }
21
22
23 YieldExpression: yield * AssignmentExpression
24
25 1. Let exprRef be the result of evaluating AssignmentExpression.
26 2. Let value be ? GetValue(exprRef).
27 3. Let generatorKind be ! GetGeneratorKind().
28 4. Let iterator be ? GetIterator(value, generatorKind).
29 ...
30
31 GetIterator ( obj [ , hint ] )
32
33 ...
34 3. If hint is async,
35 a. Set method to ? GetMethod(obj, @@asyncIterator).
36 b. If method is undefined,
37 i. Let syncMethod be ? GetMethod(obj, @@iterator).
38 ...
39
40 GetMethod ( V, P )
41
42 ...
43 2. Let func be ? GetV(V, P).
44 ...
45
46 ---*/
47 var calls = 0;
48 var reason = {};
49 var obj = {
50 get [Symbol.iterator]() {
51 throw reason;
52 },
53 get [Symbol.asyncIterator]() {
54 calls += 1;
55 return null;
56 }
57 };
58
59
60
61 var callCount = 0;
62
63 var C = class { async *gen() {
64 callCount += 1;
65 yield* obj;
66 throw new Test262Error('abrupt completion closes iter');
67
68 }}
69
70 var gen = C.prototype.gen;
71
72 var iter = gen();
73
74 iter.next().then(() => {
75 throw new Test262Error('Promise incorrectly fulfilled.');
76 }, v => {
77 assert.sameValue(v, reason, 'reject reason');
78 assert.sameValue(calls, 1);
79
80 iter.next().then(({ done, value }) => {
81 assert.sameValue(done, true, 'the iterator is completed');
82 assert.sameValue(value, undefined, 'value is undefined');
83 }).then($DONE, $DONE);
84 }).catch($DONE);
85
86 assert.sameValue(callCount, 1);