Debian Codegraph @

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