Debian Codegraph @

js/src/jit-test/tests/explicit-resource-management/syntax.js

raw
1 // |jit-test| skip-if: !getBuildConfiguration("explicit-resource-management"); --enable-explicit-resource-management
2
3 load(libdir + "asserts.js");
4
5 // Valid `using` syntaxes
6 Reflect.parse("{ using x = {} }");
7 Reflect.parse("using x = {}", { target: "module" });
8 Reflect.parse("{ using x = fn() }");
9 Reflect.parse("{ using x = fn(); }");
10 Reflect.parse("function f() { using x = fn(); }");
11 Reflect.parse("if (x == 1) { using x = fn(); }");
12 Reflect.parse("for (let i = 0; i < 10; i++) { using x = fn(); }");
13 Reflect.parse("for (const i of [1, 2, 3]) { using x = fn(); }");
14 Reflect.parse("for (const i in {a: 1, b: 2}) { using x = fn(); }");
15 Reflect.parse("function* gen() { using x = fn(); }");
16 Reflect.parse("async function* fn() { using x = fn(); }");
17 Reflect.parse("async function fn() { using x = fn(); }");
18 Reflect.parse("class xyz { static { using x = fn(); } }");
19 Reflect.parse("{ using a = fn1(), b = fn2(); }");
20 Reflect.parse("{ using x = null }");
21 Reflect.parse("{ using x = undefined }");
22 Reflect.parse("{ for (using x of y) {} }");
23 Reflect.parse("for (using x of y) {}");
24 Reflect.parse("for await (using x of y) {}", { target: "module" });
25 Reflect.parse("async function fn() { for await (using x of y) {} }");
26
27 const ast = Reflect.parse("{ using x = {} }");
28 assertEq(ast.body[0].body[0].type, "VariableDeclaration");
29 assertEq(ast.body[0].body[0].kind, "using");
30 assertEq(ast.body[0].body[0].declarations[0].type, "VariableDeclarator");
31 assertEq(ast.body[0].body[0].declarations[0].id.name, "x");
32
33 const ast2 = Reflect.parse("for (using x of y) {}");
34 assertEq(ast2.body[0].type, "ForOfStatement");
35 assertEq(ast2.body[0].left.type, "VariableDeclaration");
36 assertEq(ast2.body[0].left.kind, "using");
37 assertEq(ast2.body[0].left.declarations[0].type, "VariableDeclarator");
38 assertEq(ast2.body[0].left.declarations[0].id.type, "Identifier");
39 assertEq(ast2.body[0].left.declarations[0].id.name, "x");
40
41 const ast3 = Reflect.parse("async function fn() { for await (using x of y) {} }");
42 const forStatement = ast3.body[0].body.body[0];
43 assertEq(forStatement.type, "ForOfStatement");
44 assertEq(forStatement.left.type, "VariableDeclaration");
45 assertEq(forStatement.left.kind, "using");
46 assertEq(forStatement.left.declarations[0].type, "VariableDeclarator");
47 assertEq(forStatement.left.declarations[0].id.type, "Identifier");
48 assertEq(forStatement.left.declarations[0].id.name, "x");
49
50 // Valid `await using` syntaxes
51 Reflect.parse("await using x = {}", { target: "module" });
52 Reflect.parse("if (x == 1) { await using x = fn(); }", { target: "module" });
53 Reflect.parse("async function fn() { await using x = {}; }");
54 Reflect.parse("async function* gen() { await using x = {}; }");
55 Reflect.parse("for (let i = 0; i < 10; i++) { await using x = fn(); }", { target: "module" });
56 Reflect.parse("for (const i of [1, 2, 3]) { await using x = fn(); }", { target: "module" });
57 Reflect.parse("for (const i in {a: 1, b: 2}) { await using x = fn(); }", { target: "module" });
58 Reflect.parse("for (await using x of y) {}", { target: "module" });
59 Reflect.parse("for await (await using x of y) {}", { target: "module" });
60 Reflect.parse("async function fn() { for (await using x of y) {} }");
61 Reflect.parse("async function fn() { for await (await using x of y) {} }");
62
63 const ast16 = Reflect.parse("await using x = {}", { target: "module" });
64 assertEq(ast16.body[0].type, "VariableDeclaration");
65 assertEq(ast16.body[0].kind, "await using");
66 assertEq(ast16.body[0].declarations[0].type, "VariableDeclarator");
67 assertEq(ast16.body[0].declarations[0].id.name, "x");
68
69 const ast17 = Reflect.parse("for (await using x of y) {}", { target: "module" });
70 assertEq(ast17.body[0].type, "ForOfStatement");
71 assertEq(ast17.body[0].left.type, "VariableDeclaration");
72 assertEq(ast17.body[0].left.kind, "await using");
73 assertEq(ast17.body[0].left.declarations[0].type, "VariableDeclarator");
74 assertEq(ast17.body[0].left.declarations[0].id.type, "Identifier");
75 assertEq(ast17.body[0].left.declarations[0].id.name, "x");
76
77 const ast18 = Reflect.parse("for await (await using x of y) {}", { target: "module" });
78 assertEq(ast18.body[0].type, "ForOfStatement");
79 assertEq(ast18.body[0].left.type, "VariableDeclaration");
80 assertEq(ast18.body[0].left.kind, "await using");
81 assertEq(ast18.body[0].left.declarations[0].type, "VariableDeclarator");
82 assertEq(ast18.body[0].left.declarations[0].id.type, "Identifier");
83 assertEq(ast18.body[0].left.declarations[0].id.name, "x");
84
85 // Invalid `using` syntaxes
86 assertThrowsInstanceOf(() => Reflect.parse("using x = {}"), SyntaxError);
87 assertThrowsInstanceOf(() => Reflect.parse("{ const using x = fn() }"), SyntaxError);
88 assertThrowsInstanceOf(() => Reflect.parse("{ let using x = fn() }"), SyntaxError);
89 assertThrowsInstanceOf(() => Reflect.parse("{ var using x = fn() }"), SyntaxError);
90 assertThrowsInstanceOf(() => Reflect.parse("{ using const x = fn() }"), SyntaxError);
91 assertThrowsInstanceOf(() => Reflect.parse("{ using let x = fn() }"), SyntaxError);
92 assertThrowsInstanceOf(() => Reflect.parse("{ using var x = fn() }"), SyntaxError);
93 assertThrowsInstanceOf(() => Reflect.parse("{ using x = fn(), x = fn() }"), SyntaxError);
94 assertThrowsInstanceOf(() => Reflect.parse("for (using x in y) {}"), SyntaxError);
95 assertThrowsInstanceOf(() => Reflect.parse("for (using\nx of y) {}"), SyntaxError);
96 assertThrowsInstanceOf(() => Reflect.parse("for (using of of y) {}"), SyntaxError);
97 assertThrowsInstanceOf(() => Reflect.parse("{ using /a/; }"), SyntaxError);
98 assertThrowsInstanceOf(() => Reflect.parse("for (using /a/g of y) {}"), SyntaxError);
99 assertThrowsInstanceOf(() => Reflect.parse("if(1) using x = {}"), SyntaxError);
100 assertThrowsInstanceOf(() => Reflect.parse("for (;;) using x = 10;"), SyntaxError);
101 assertThrowsInstanceOf(() => Reflect.parse("foo: using x = 10;"), SyntaxError);
102 assertThrowsInstanceOf(() => Reflect.parse("export using x = 10", { target: "module" }), SyntaxError);
103 assertThrowsInstanceOf(() => Reflect.parse("{ using a }"), SyntaxError);
104 assertThrowsInstanceOf(() => Reflect.parse("{ using a, b }"), SyntaxError);
105 assertThrowsInstanceOf(() => Reflect.parse("switch (x) { case 1: using x = fn(); }"), SyntaxError);
106 assertThrowsInstanceOf(() => Reflect.parse("switch (x) { case 1: break; default: using x = fn(); }"), SyntaxError);
107
108 // Invalid `await using` syntaxes
109 assertThrowsInstanceOf(() => Reflect.parse("{ await using }"), SyntaxError);
110 assertThrowsInstanceOf(() => Reflect.parse("await using x = fn(), x = fn()", { target: "module" }), SyntaxError);
111 assertThrowsInstanceOf(() => Reflect.parse("async function fn() { await using x = fn(), x = fn(); }"), SyntaxError);
112 assertThrowsInstanceOf(() => Reflect.parse("for (await using x in y) {}", { target: "module" }), SyntaxError);
113 assertThrowsInstanceOf(() => Reflect.parse("async function fn() { for (await using x in y) {} }"), SyntaxError);
114 assertThrowsInstanceOf(() => Reflect.parse("for (await using\nx of y) {}", { target: "module" }), SyntaxError);
115 assertThrowsInstanceOf(() => Reflect.parse("for (await\nusing x of y) {}", { target: "module" }), SyntaxError);
116 assertThrowsInstanceOf(() => Reflect.parse("async function fn() { for (await\nusing x of y) {} }"), SyntaxError);
117 assertThrowsInstanceOf(() => Reflect.parse("async function fn() { for (await using\nx of y) {} }"), SyntaxError);
118 assertThrowsInstanceOf(() => Reflect.parse("for (await using;;) {}"), SyntaxError);
119 assertThrowsInstanceOf(() => Reflect.parse("await using /a/;", { target: "module" }), SyntaxError);
120 assertThrowsInstanceOf(() => Reflect.parse("for (await using /a/g of y) {}", { target: "module" }), SyntaxError);
121 assertThrowsInstanceOf(() => Reflect.parse("if(1) await using x = {}", { target: "module" }), SyntaxError);
122 assertThrowsInstanceOf(() => Reflect.parse("for (;;) await using x = 10;", { target: "module" }), SyntaxError);
123 assertThrowsInstanceOf(() => Reflect.parse("foo: await using x = 10;", { target: "module" }), SyntaxError);
124 assertThrowsInstanceOf(() => Reflect.parse("export await using x = 10", { target: "module" }), SyntaxError);
125 assertThrowsInstanceOf(() => Reflect.parse("for (await using [x,y] of z) {}", { target: "module" }), SyntaxError);
126 assertThrowsInstanceOf(() => Reflect.parse("for (await using {x,y} of z) {}", { target: "module" }), SyntaxError);
127 assertThrowsInstanceOf(() => Reflect.parse("{ await using a }", { target: "module" }), SyntaxError);
128 assertThrowsInstanceOf(() => Reflect.parse("{ await using a, b }", { target: "module" }), SyntaxError);
129 assertThrowsInstanceOf(() => Reflect.parse("switch (x) { case 1: await using x = fn(); }", { target: "module" }), SyntaxError);
130 assertThrowsInstanceOf(() => Reflect.parse("switch (x) { case 1: break; default: await using x = fn(); }", { target: "module" }), SyntaxError);
131
132 // Valid usage of `using` syntax with contextual keywords
133 Reflect.parse("{ using await = {}; }");
134 Reflect.parse("{ using yield = {}; }");
135 Reflect.parse("{ using public = {}; }");
136 Reflect.parse("{ using private = {}; }");
137 Reflect.parse("{ using protected = {}; }");
138 Reflect.parse("{ using static = {}; }");
139 Reflect.parse("{ using as = {}; }");
140 Reflect.parse("{ using async = {}; }");
141 Reflect.parse("{ using implements = {}; }");
142 Reflect.parse("{ using interface = {}; }");
143 Reflect.parse("{ using package = {}; }");
144 Reflect.parse("'use strict'; { using await = {}; }");
145 Reflect.parse("for (using await of y) {}");
146 Reflect.parse("for (using yield of y) {}");
147 Reflect.parse("using async = {};", { target: "module" });
148 Reflect.parse("await using async = {};", { target: "module" });
149 Reflect.parse("async function fn() { using async = {}; }");
150
151 // Valid usage of `await using` syntax with contextual keywords.
152 Reflect.parse("async function fn() { await using yield = {} }");
153 Reflect.parse("async function fn() { await using public = {} }");
154 Reflect.parse("async function fn() { await using private = {} }");
155 Reflect.parse("async function fn() { await using protected = {} }");
156 Reflect.parse("async function fn() { await using static = {} }");
157 Reflect.parse("async function fn() { await using as = {} }");
158 Reflect.parse("async function fn() { await using async = {} }");
159 Reflect.parse("async function fn() { await using implements = {} }");
160 Reflect.parse("async function fn() { await using package = {}; }");
161 Reflect.parse("await using as = {}", { target: "module" });
162 Reflect.parse("await using async = {};", { target: "module" });
163 Reflect.parse("for (await using of of y) {}", { target: "module" })
164
165 // Invalid usage of `using` syntax with contextual keywords.
166 assertThrowsInstanceOf(() => Reflect.parse("{ using let = {} }"), SyntaxError);
167 assertThrowsInstanceOf(() => Reflect.parse("using await = {}", { target: "module" }), SyntaxError);
168 assertThrowsInstanceOf(() => Reflect.parse("async function fn() { using await = {}; }"), SyntaxError);
169 assertThrowsInstanceOf(() => Reflect.parse("async function fn() { for (using await of y) {} }"), SyntaxError);
170 assertThrowsInstanceOf(() => Reflect.parse("'use strict'; { using yield = {}; }"), SyntaxError);
171 assertThrowsInstanceOf(() => Reflect.parse("'use strict'; { using public = {}; }"), SyntaxError);
172 assertThrowsInstanceOf(() => Reflect.parse("'use strict'; { using private = {}; }"), SyntaxError);
173 assertThrowsInstanceOf(() => Reflect.parse("'use strict'; { using protected = {}; }"), SyntaxError);
174 assertThrowsInstanceOf(() => Reflect.parse("'use strict'; { using static = {}; }"), SyntaxError);
175 assertThrowsInstanceOf(() => Reflect.parse("'use strict'; { using implements = {}; }"), SyntaxError);
176 assertThrowsInstanceOf(() => Reflect.parse("'use strict'; { using interface = {}; }"), SyntaxError);
177 assertThrowsInstanceOf(() => Reflect.parse("'use strict'; { using package = {}; }"), SyntaxError);
178 assertThrowsInstanceOf(() => Reflect.parse("'use strict'; for (using yield of y) {}"), SyntaxError);
179 assertThrowsInstanceOf(() => Reflect.parse("function* gen() { using yield = {}; }"), SyntaxError);
180 assertThrowsInstanceOf(() => Reflect.parse("for (using await of y) {}", { target: "module" }), SyntaxError);
181 assertThrowsInstanceOf(() => Reflect.parse("async function fn() { for (using await of y) {} }"), SyntaxError);
182 assertThrowsInstanceOf(() => Reflect.parse("function* gen() { for (using yield of y) {} }"), SyntaxError);
183
184 // Invalid usage of `await using` syntax with contextual keywords.
185 assertThrowsInstanceOf(() => Reflect.parse("await using yield = {};", { target: "module" }), SyntaxError);
186 assertThrowsInstanceOf(() => Reflect.parse("await using public = {};", { target: "module" }), SyntaxError);
187 assertThrowsInstanceOf(() => Reflect.parse("await using private = {};", { target: "module" }), SyntaxError);
188 assertThrowsInstanceOf(() => Reflect.parse("await using protected = {};", { target: "module" }), SyntaxError);
189 assertThrowsInstanceOf(() => Reflect.parse("await using static = {};", { target: "module" }), SyntaxError);
190 assertThrowsInstanceOf(() => Reflect.parse("await using implements = {};", { target: "module" }), SyntaxError);
191 assertThrowsInstanceOf(() => Reflect.parse("await using interface = {};", { target: "module" }), SyntaxError);
192 assertThrowsInstanceOf(() => Reflect.parse("await using package = {};", { target: "module" }), SyntaxError);
193 assertThrowsInstanceOf(() => Reflect.parse("await using await = {};", { target: "module" }), SyntaxError);
194 assertThrowsInstanceOf(() => Reflect.parse("async function fn() { await using await = {} }"), SyntaxError);
195 assertThrowsInstanceOf(() => Reflect.parse("'use strict'; async function fn() { await using await = {} }"), SyntaxError);
196 assertThrowsInstanceOf(() => Reflect.parse("'use strict'; async function fn() { await using yield = {} }"), SyntaxError);
197 assertThrowsInstanceOf(() => Reflect.parse("'use strict'; async function fn() { await using public = {} }"), SyntaxError);
198 assertThrowsInstanceOf(() => Reflect.parse("'use strict'; async function fn() { await using private = {} }"), SyntaxError);
199 assertThrowsInstanceOf(() => Reflect.parse("'use strict'; async function fn() { await using protected = {} }"), SyntaxError);
200 assertThrowsInstanceOf(() => Reflect.parse("'use strict'; async function fn() { await using static = {} }"), SyntaxError);
201 assertThrowsInstanceOf(() => Reflect.parse("'use strict'; async function fn() { await using implements = {} }"), SyntaxError);
202 assertThrowsInstanceOf(() => Reflect.parse("'use strict'; async function fn() { await using package = {} }"), SyntaxError);
203 assertThrowsInstanceOf(() => Reflect.parse("async function* gen() { await using yield = {}; } "), SyntaxError);
204 assertThrowsInstanceOf(() => Reflect.parse("async function fn() { for (await using await of y) {} }"), SyntaxError);
205 assertThrowsInstanceOf(() => Reflect.parse("async function* gen() { for (await using yield of y) {} }"), SyntaxError);
206
207 // Valid syntaxes close to `using` but not `using` declarations.
208 Reflect.parse("for (using of y) {}");
209 Reflect.parse("for (using of of) {}");
210 Reflect.parse("for (using\nof y) {}");
211 Reflect.parse("{ const using = 10; }");
212 Reflect.parse("{ let using = 10 }");
213 Reflect.parse("{ var using = 10 }");
214 Reflect.parse("{ using = 10 }");
215 Reflect.parse("{ using + 1 }");
216 Reflect.parse("{ using++ }");
217 Reflect.parse("{ using\nx = 10 }");
218 Reflect.parse("{ using = {x: 10} }");
219 Reflect.parse("{ x = { using: 10 } }");
220 Reflect.parse("{ x.using = 10 }");
221 Reflect.parse("{ x\n.using = 10 }");
222 Reflect.parse("{ using.x = 10 }");
223 Reflect.parse("{ using\n.x = 10 }");
224 Reflect.parse("for (using[1] of {}) {}");
225 Reflect.parse("for (using\n[1] of {}) {}")
226 Reflect.parse("for (using.x of {}) {}");
227 Reflect.parse("for (using\n.x of {}) {}");
228 Reflect.parse("for (x.using in {}) {}");
229 Reflect.parse("for (x\n.using in {}) {}")
230 Reflect.parse("{ using: x = 10; }");
231 Reflect.parse("{ using\n: x = 10; }");
232 Reflect.parse("{ using /a/g; }");
233 Reflect.parse("{ /using/g }");
234 Reflect.parse("{ using\nlet = {} }");
235 Reflect.parse("export const using = 10", { target: "module" });
236 Reflect.parse("import using from 'xyz'", { target: "module" });
237 Reflect.parse("switch (x) { case 1: using: fn(); }");
238 Reflect.parse("switch (x) { case 1: break; default: using: fn(); }");
239
240 const ast4 = Reflect.parse("{ using = 10 }");
241 assertEq(ast4.body[0].body[0].type, "ExpressionStatement");
242 assertEq(ast4.body[0].body[0].expression.type, "AssignmentExpression");
243 assertEq(ast4.body[0].body[0].expression.left.type, "Identifier");
244 assertEq(ast4.body[0].body[0].expression.left.name, "using");
245
246 const ast5 = Reflect.parse("for (using of y) {}");
247 assertEq(ast5.body[0].type, "ForOfStatement");
248 assertEq(ast5.body[0].left.type, "Identifier");
249 assertEq(ast5.body[0].left.name, "using");
250
251 const ast6 = Reflect.parse("{ using + 1 }");
252 assertEq(ast6.body[0].body[0].type, "ExpressionStatement");
253 assertEq(ast6.body[0].body[0].expression.type, "BinaryExpression");
254 assertEq(ast6.body[0].body[0].expression.left.type, "Identifier");
255 assertEq(ast6.body[0].body[0].expression.left.name, "using");
256
257 const ast7 = Reflect.parse("for (using of of) {}");
258 assertEq(ast7.body[0].type, "ForOfStatement");
259 assertEq(ast7.body[0].left.type, "Identifier");
260 assertEq(ast7.body[0].left.name, "using");
261 assertEq(ast7.body[0].right.type, "Identifier");
262 assertEq(ast7.body[0].right.name, "of");
263
264 const ast8 = Reflect.parse("for (using\nof y) {}");
265 assertEq(ast8.body[0].type, "ForOfStatement");
266 assertEq(ast8.body[0].left.type, "Identifier");
267 assertEq(ast8.body[0].left.name, "using");
268 assertEq(ast8.body[0].right.type, "Identifier");
269 assertEq(ast8.body[0].right.name, "y");
270
271 const ast9 = Reflect.parse("for (using[1] of {}) {}");
272 assertEq(ast9.body[0].type, "ForOfStatement");
273 assertEq(ast9.body[0].left.type, "MemberExpression");
274 assertEq(ast9.body[0].left.object.type, "Identifier");
275 assertEq(ast9.body[0].left.object.name, "using");
276 assertEq(ast9.body[0].left.property.type, "Literal");
277 assertEq(ast9.body[0].left.property.value, 1);
278
279 const ast10 = Reflect.parse("for (using\n[1] of {}) {}");
280 assertEq(ast10.body[0].type, "ForOfStatement");
281 assertEq(ast10.body[0].left.type, "MemberExpression");
282 assertEq(ast10.body[0].left.object.type, "Identifier");
283 assertEq(ast10.body[0].left.object.name, "using");
284 assertEq(ast10.body[0].left.property.type, "Literal");
285 assertEq(ast10.body[0].left.property.value, 1);
286
287 const ast11 = Reflect.parse("{ /using/g }");
288 assertEq(ast11.body[0].body[0].type, "ExpressionStatement");
289 assertEq(ast11.body[0].body[0].expression.type, "Literal");
290 assertEq(ast11.body[0].body[0].expression.value.source, "using");
291 assertEq(ast11.body[0].body[0].expression.value.flags, "g");
292
293 const ast12 = Reflect.parse("{ using: x = 10; }");
294 assertEq(ast12.body[0].body[0].type, "LabeledStatement");
295 assertEq(ast12.body[0].body[0].label.type, "Identifier");
296 assertEq(ast12.body[0].body[0].label.name, "using");
297
298 const ast13 = Reflect.parse("{ using\n: x = 10; }");
299 assertEq(ast13.body[0].body[0].type, "LabeledStatement");
300 assertEq(ast13.body[0].body[0].label.type, "Identifier");
301 assertEq(ast13.body[0].body[0].label.name, "using");
302
303 const ast14 = Reflect.parse("{ using /a/g; }");
304 // should be parsed as division, not regex
305 assertEq(ast14.body[0].body[0].type, "ExpressionStatement");
306 assertEq(ast14.body[0].body[0].expression.type, "BinaryExpression");
307 assertEq(ast14.body[0].body[0].expression.operator, "/");
308 assertEq(ast14.body[0].body[0].expression.left.type, "BinaryExpression");
309 assertEq(ast14.body[0].body[0].expression.left.operator, "/");
310
311 const ast15 = Reflect.parse("import using from 'xyz'", { target: "module" });
312 assertEq(ast15.body[0].type, "ImportDeclaration");
313 assertEq(ast15.body[0].specifiers[0].type, "ImportSpecifier");
314 assertEq(ast15.body[0].specifiers[0].name.name, "using");
315
316 // Valid syntaxes close to `await using` but not `await using` declarations.
317 Reflect.parse("await /xyz/g");
318 Reflect.parse("{ await /using/g }");
319 Reflect.parse("async function fn() { await using; }");
320 Reflect.parse("async function fn() { await\nusing; }")
321 Reflect.parse("async function fn() { await /using/g }");
322 Reflect.parse("async function fn() { await using/g }");
323 Reflect.parse("async function fn() { await using/\ng }");
324 Reflect.parse("async function fn() { for(await using;;) {} }");
325 Reflect.parse("await using;", { target: "module" });
326 Reflect.parse("await\nusing;", { target: "module" });
327 Reflect.parse("await /using/g", { target: "module" });
328 Reflect.parse("await using/g", { target: "module" });
329 Reflect.parse("await using/\ng", { target: "module" });
330 Reflect.parse("for(await using;;) {}", { target: "module" });
331 Reflect.parse("await using\nx;", { target: "module" });
332
333 const ast19 = Reflect.parse("await using", { target: "module" });
334 assertEq(ast19.body[0].type, "ExpressionStatement");
335 assertEq(ast19.body[0].expression.type, "UnaryExpression");
336 assertEq(ast19.body[0].expression.operator, "await");
337 assertEq(ast19.body[0].expression.argument.type, "Identifier");
338 assertEq(ast19.body[0].expression.argument.name, "using");
339
340 const ast20 = Reflect.parse("await /using/g", { target: "module" });
341 assertEq(ast20.body[0].type, "ExpressionStatement");
342 assertEq(ast20.body[0].expression.type, "UnaryExpression");
343 assertEq(ast20.body[0].expression.operator, "await");
344 assertEq(ast20.body[0].expression.argument.type, "Literal");
345 assertEq(ast20.body[0].expression.argument.value.source, "using");
346 assertEq(ast20.body[0].expression.argument.value.flags, "g");
347
348 const ast21 = Reflect.parse("await using/g", { target: "module" });
349 assertEq(ast21.body[0].type, "ExpressionStatement");
350 assertEq(ast21.body[0].expression.type, "BinaryExpression");
351 assertEq(ast21.body[0].expression.operator, "/");
352 assertEq(ast21.body[0].expression.left.type, "UnaryExpression");
353 assertEq(ast21.body[0].expression.left.operator, "await");
354 assertEq(ast21.body[0].expression.left.argument.type, "Identifier");
355 assertEq(ast21.body[0].expression.left.argument.name, "using");
356
357 const ast22 = Reflect.parse("for(await using;;) {}", { target: "module" });
358 assertEq(ast22.body[0].type, "ForStatement");
359 assertEq(ast22.body[0].init.type, "UnaryExpression");
360 assertEq(ast22.body[0].init.operator, "await");
361 assertEq(ast22.body[0].init.argument.type, "Identifier");
362 assertEq(ast22.body[0].init.argument.name, "using");