Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/language/expressions/object/method-definition/async-gen-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-obj-method.template
4 /*---
5 description: Execution order for yield* with async iterator and next() (Async generator method)
6 esid: prod-AsyncGeneratorMethod
7 features: [Symbol.iterator, async-iteration, Symbol.asyncIterator]
8 flags: [generated, async]
9 info: |
10 Async Generator Function Definitions
11
12 AsyncGeneratorMethod :
13 async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody }
14
15
16
17 ---*/
18 var log = [];
19 var obj = {
20 get [Symbol.iterator]() {
21 log.push({ name: "get [Symbol.iterator]" });
22 },
23 get [Symbol.asyncIterator]() {
24 log.push({
25 name: "get [Symbol.asyncIterator]",
26 thisValue: this
27 });
28 return function() {
29 log.push({
30 name: "call [Symbol.asyncIterator]",
31 thisValue: this,
32 args: [...arguments]
33 });
34 var nextCount = 0;
35 return {
36 name: "asyncIterator",
37 get next() {
38 log.push({
39 name: "get next",
40 thisValue: this
41 });
42 return function() {
43 log.push({
44 name: "call next",
45 thisValue: this,
46 args: [...arguments]
47 });
48
49 nextCount++;
50 if (nextCount == 1) {
51 return {
52 name: "next-promise-1",
53 get then() {
54 log.push({
55 name: "get next then (1)",
56 thisValue: this
57 });
58 return function(resolve) {
59 log.push({
60 name: "call next then (1)",
61 thisValue: this,
62 args: [...arguments]
63 });
64
65 resolve({
66 name: "next-result-1",
67 get value() {
68 log.push({
69 name: "get next value (1)",
70 thisValue: this
71 });
72 return "next-value-1";
73 },
74 get done() {
75 log.push({
76 name: "get next done (1)",
77 thisValue: this
78 });
79 return false;
80 }
81 });
82 };
83 }
84 };
85 }
86
87 return {
88 name: "next-promise-2",
89 get then() {
90 log.push({
91 name: "get next then (2)",
92 thisValue: this
93 });
94 return function(resolve) {
95 log.push({
96 name: "call next then (2)",
97 thisValue: this,
98 args: [...arguments]
99 });
100
101 resolve({
102 name: "next-result-2",
103 get value() {
104 log.push({
105 name: "get next value (2)",
106 thisValue: this
107 });
108 return "next-value-2";
109 },
110 get done() {
111 log.push({
112 name: "get next done (2)",
113 thisValue: this
114 });
115 return true;
116 }
117 });
118 };
119 }
120 };
121 };
122 }
123 };
124 };
125 }
126 };
127
128
129 var callCount = 0;
130
131 var gen = {
132 async *method() {
133 callCount += 1;
134 log.push({ name: "before yield*" });
135 var v = yield* obj;
136 log.push({
137 name: "after yield*",
138 value: v
139 });
140 return "return-value";
141
142 }
143 }.method;
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);