Debian Codegraph @

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

raw
1 // This file was procedurally generated from the following sources:
2 // - src/async-generators/yield-star-next-get-abrupt.case
3 // - src/async-generators/default/async-class-expr-static-method.template
4 /*---
5 description: Abrupt completion while getting next (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 ...
29
30 ---*/
31 var reason = {};
32 var obj = {
33 get [Symbol.iterator]() {
34 throw new Test262Error('it should not get Symbol.iterator');
35 },
36 [Symbol.asyncIterator]() {
37 return {
38 get next() {
39 throw reason;
40 }
41 };
42 }
43 };
44
45
46
47 var callCount = 0;
48
49 var C = class { static async *gen() {
50 callCount += 1;
51 yield* obj;
52 throw new Test262Error('abrupt completion closes iter');
53
54 }}
55
56 var gen = C.gen;
57
58 var iter = gen();
59
60 iter.next().then(() => {
61 throw new Test262Error('Promise incorrectly fulfilled.');
62 }, v => {
63 assert.sameValue(v, reason, "reject reason");
64
65 iter.next().then(({ done, value }) => {
66 assert.sameValue(done, true, 'the iterator is completed');
67 assert.sameValue(value, undefined, 'value is undefined');
68 }).then($DONE, $DONE);
69 }).catch($DONE);
70
71 assert.sameValue(callCount, 1);