Debian Codegraph @

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

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