Debian Codegraph @

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

raw
1 // This file was procedurally generated from the following sources:
2 // - src/async-generators/yield-star-async-next.case
3 // - src/async-generators/default/async-class-expr-static-method.template
4 /*---
5 description: Execution order for yield* with async iterator and next() (Static async generator method as a ClassExpression element)
6 esid: prod-AsyncGeneratorMethod
7 features: [Symbol.iterator, async-iteration, Symbol.asyncIterator]
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
23 ---*/
24 var log = [];
25 var obj = {
26 get [Symbol.iterator]() {
27 log.push({ name: "get [Symbol.iterator]" });
28 },
29 get [Symbol.asyncIterator]() {
30 log.push({
31 name: "get [Symbol.asyncIterator]",
32 thisValue: this
33 });
34 return function() {
35 log.push({
36 name: "call [Symbol.asyncIterator]",
37 thisValue: this,
38 args: [...arguments]
39 });
40 var nextCount = 0;
41 return {
42 name: "asyncIterator",
43 get next() {
44 log.push({
45 name: "get next",
46 thisValue: this
47 });
48 return function() {
49 log.push({
50 name: "call next",
51 thisValue: this,
52 args: [...arguments]
53 });
54
55 nextCount++;
56 if (nextCount == 1) {
57 return {
58 name: "next-promise-1",
59 get then() {
60 log.push({
61 name: "get next then (1)",
62 thisValue: this
63 });
64 return function(resolve) {
65 log.push({
66 name: "call next then (1)",
67 thisValue: this,
68 args: [...arguments]
69 });
70
71 resolve({
72 name: "next-result-1",
73 get value() {
74 log.push({
75 name: "get next value (1)",
76 thisValue: this
77 });
78 return "next-value-1";
79 },
80 get done() {
81 log.push({
82 name: "get next done (1)",
83 thisValue: this
84 });
85 return false;
86 }
87 });
88 };
89 }
90 };
91 }
92
93 return {
94 name: "next-promise-2",
95 get then() {
96 log.push({
97 name: "get next then (2)",
98 thisValue: this
99 });
100 return function(resolve) {
101 log.push({
102 name: "call next then (2)",
103 thisValue: this,
104 args: [...arguments]
105 });
106
107 resolve({
108 name: "next-result-2",
109 get value() {
110 log.push({
111 name: "get next value (2)",
112 thisValue: this
113 });
114 return "next-value-2";
115 },
116 get done() {
117 log.push({
118 name: "get next done (2)",
119 thisValue: this
120 });
121 return true;
122 }
123 });
124 };
125 }
126 };
127 };
128 }
129 };
130 };
131 }
132 };
133
134
135
136 var callCount = 0;
137
138 var C = class { static async *gen() {
139 callCount += 1;
140 log.push({ name: "before yield*" });
141 var v = yield* obj;
142 log.push({
143 name: "after yield*",
144 value: v
145 });
146 return "return-value";
147
148 }}
149
150 var gen = C.gen;
151
152 var iter = gen();
153
154 assert.sameValue(log.length, 0, "log.length");
155
156 iter.next("next-arg-1").then(v => {
157 assert.sameValue(log[0].name, "before yield*");
158
159 assert.sameValue(log[1].name, "get [Symbol.asyncIterator]");
160 assert.sameValue(log[1].thisValue, obj, "get [Symbol.asyncIterator] thisValue");
161
162 assert.sameValue(log[2].name, "call [Symbol.asyncIterator]");
163 assert.sameValue(log[2].thisValue, obj, "[Symbol.asyncIterator] thisValue");
164 assert.sameValue(log[2].args.length, 0, "[Symbol.asyncIterator] args.length");
165
166 assert.sameValue(log[3].name, "get next");
167 assert.sameValue(log[3].thisValue.name, "asyncIterator", "get next thisValue");
168
169 assert.sameValue(log[4].name, "call next");
170 assert.sameValue(log[4].thisValue.name, "asyncIterator", "next thisValue");
171 assert.sameValue(log[4].args.length, 1, "next args.length");
172 assert.sameValue(log[4].args[0], undefined, "next args[0]");
173
174 assert.sameValue(log[5].name, "get next then (1)");
175 assert.sameValue(log[5].thisValue.name, "next-promise-1", "get next then thisValue");
176
177 assert.sameValue(log[6].name, "call next then (1)");
178 assert.sameValue(log[6].thisValue.name, "next-promise-1", "next then thisValue");
179 assert.sameValue(log[6].args.length, 2, "next then args.length");
180 assert.sameValue(typeof log[6].args[0], "function", "next then args[0]");
181 assert.sameValue(typeof log[6].args[1], "function", "next then args[1]");
182
183 assert.sameValue(log[7].name, "get next done (1)");
184 assert.sameValue(log[7].thisValue.name, "next-result-1", "get next done thisValue");
185
186 assert.sameValue(log[8].name, "get next value (1)");
187 assert.sameValue(log[8].thisValue.name, "next-result-1", "get next value thisValue");
188
189 assert.sameValue(v.value, "next-value-1");
190 assert.sameValue(v.done, false);
191
192 assert.sameValue(log.length, 9, "log.length");
193
194 iter.next("next-arg-2").then(v => {
195 assert.sameValue(log[9].name, "call next");
196 assert.sameValue(log[9].thisValue.name, "asyncIterator", "next thisValue");
197 assert.sameValue(log[9].args.length, 1, "next args.length");
198 assert.sameValue(log[9].args[0], "next-arg-2", "next args[0]");
199
200 assert.sameValue(log[10].name, "get next then (2)");
201 assert.sameValue(log[10].thisValue.name, "next-promise-2", "get next then thisValue");
202
203 assert.sameValue(log[11].name, "call next then (2)");
204 assert.sameValue(log[11].thisValue.name, "next-promise-2", "next then thisValue");
205 assert.sameValue(log[11].args.length, 2, "next then args.length");
206 assert.sameValue(typeof log[11].args[0], "function", "next then args[0]");
207 assert.sameValue(typeof log[11].args[1], "function", "next then args[1]");
208
209 assert.sameValue(log[12].name, "get next done (2)");
210 assert.sameValue(log[12].thisValue.name, "next-result-2", "get next done thisValue");
211
212 assert.sameValue(log[13].name, "get next value (2)");
213 assert.sameValue(log[13].thisValue.name, "next-result-2", "get next value thisValue");
214
215 assert.sameValue(log[14].name, "after yield*");
216 assert.sameValue(log[14].value, "next-value-2");
217
218 assert.sameValue(v.value, "return-value");
219 assert.sameValue(v.done, true);
220
221 assert.sameValue(log.length, 15, "log.length");
222 }).then($DONE, $DONE);
223 }).catch($DONE);
224
225 assert.sameValue(callCount, 1);