diff --git a/test/language/statements/using/syntax/block-scope-syntax-using-declarations-mixed-with-without-initializer.js b/test/language/statements/using/syntax/block-scope-syntax-using-declarations-mixed-with-without-initializer.js new file mode 100644 index 00000000000..15977b30142 --- /dev/null +++ b/test/language/statements/using/syntax/block-scope-syntax-using-declarations-mixed-with-without-initializer.js @@ -0,0 +1,30 @@ +// Copyright (C) 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-let-and-const-declarations-static-semantics-early-errors +description: > + using declarations mixed: with, without initializer +info: | + Static Semantics : Early Errors + LexicalBinding : BindingIdentifier Initializer? + + - It is a Syntax Error if Initializer is not present and IsConstantDeclaration of the LexicalDeclaration containing + this LexicalBinding is true. + + Static Semantics : IsConstantDeclaration + UsingDeclaration : + `using` BindingList ; + + 1. Return true. + +negative: + phase: parse + type: SyntaxError +features: [explicit-resource-management] +---*/ + +$DONOTEVALUATE(); +{ + using x = null, y; +} diff --git a/test/language/statements/using/syntax/block-scope-syntax-using-declarations-mixed-without-with-initializer.js b/test/language/statements/using/syntax/block-scope-syntax-using-declarations-mixed-without-with-initializer.js new file mode 100644 index 00000000000..133dff75d08 --- /dev/null +++ b/test/language/statements/using/syntax/block-scope-syntax-using-declarations-mixed-without-with-initializer.js @@ -0,0 +1,30 @@ +// Copyright (C) 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-let-and-const-declarations-static-semantics-early-errors +description: > + using declarations mixed: without, with initializer +info: | + Static Semantics : Early Errors + LexicalBinding : BindingIdentifier Initializer? + + - It is a Syntax Error if Initializer is not present and IsConstantDeclaration of the LexicalDeclaration containing + this LexicalBinding is true. + + Static Semantics : IsConstantDeclaration + UsingDeclaration : + `using` BindingList ; + + 1. Return true. + +negative: + phase: parse + type: SyntaxError +features: [explicit-resource-management] +---*/ + +$DONOTEVALUATE(); +{ + using x, y = null; +} diff --git a/test/language/statements/using/syntax/block-scope-syntax-using-declarations-without-initializer.js b/test/language/statements/using/syntax/block-scope-syntax-using-declarations-without-initializer.js new file mode 100644 index 00000000000..69a074385f0 --- /dev/null +++ b/test/language/statements/using/syntax/block-scope-syntax-using-declarations-without-initializer.js @@ -0,0 +1,30 @@ +// Copyright (C) 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-let-and-const-declarations-static-semantics-early-errors +description: > + using declarations without initializer +info: | + Static Semantics : Early Errors + LexicalBinding : BindingIdentifier Initializer? + + - It is a Syntax Error if Initializer is not present and IsConstantDeclaration of the LexicalDeclaration containing + this LexicalBinding is true. + + Static Semantics : IsConstantDeclaration + UsingDeclaration : + `using` BindingList ; + + 1. Return true. + +negative: + phase: parse + type: SyntaxError +features: [explicit-resource-management] +---*/ + +$DONOTEVALUATE(); +{ + using x; +} diff --git a/test/language/statements/using/syntax/using-allowed-at-top-level-of-module.js b/test/language/statements/using/syntax/using-allowed-at-top-level-of-module.js new file mode 100644 index 00000000000..2187c8b3770 --- /dev/null +++ b/test/language/statements/using/syntax/using-allowed-at-top-level-of-module.js @@ -0,0 +1,19 @@ +// Copyright (C) 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-let-const-using-and-await-using-declarations-static-semantics-early-errors +description: > + using declarations allowed at the top level of a module +info: | + UsingDeclaration : using BindingList ; + + - It is a Syntax Error if the goal symbol is Script and UsingDeclaration is not contained, either directly or + indirectly, within a Block, ForStatement, ForInOfStatement, FunctionBody, GeneratorBody, + AsyncGeneratorBody, AsyncFunctionBody, ClassStaticBlockBody, or ClassBody. + +flags: [module] +features: [explicit-resource-management] +---*/ + +using x = null; diff --git a/test/language/statements/using/syntax/using-allows-bindingidentifier.js b/test/language/statements/using/syntax/using-allows-bindingidentifier.js new file mode 100644 index 00000000000..f6e1f058aed --- /dev/null +++ b/test/language/statements/using/syntax/using-allows-bindingidentifier.js @@ -0,0 +1,12 @@ +// Copyright (C) 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-let-const-using-and-await-using-declarations +description: > + 'using' allows BindingIdentifier in lexical bindings +features: [explicit-resource-management] +---*/ +{ + using x = null; +} diff --git a/test/language/statements/using/syntax/using-allows-multiple-bindings.js b/test/language/statements/using/syntax/using-allows-multiple-bindings.js new file mode 100644 index 00000000000..8f457935373 --- /dev/null +++ b/test/language/statements/using/syntax/using-allows-multiple-bindings.js @@ -0,0 +1,13 @@ +// Copyright (C) 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-let-const-using-and-await-using-declarations +description: > + 'using' allows multiple lexical bindings +features: [explicit-resource-management] +---*/ + +{ + using x = null, y = null; +} diff --git a/test/language/statements/using/syntax/using-declaring-let-split-across-two-lines.js b/test/language/statements/using/syntax/using-declaring-let-split-across-two-lines.js new file mode 100644 index 00000000000..393ff53e87c --- /dev/null +++ b/test/language/statements/using/syntax/using-declaring-let-split-across-two-lines.js @@ -0,0 +1,20 @@ +// Copyright (C) 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-let-const-using-and-await-using-declarations +description: > + using: |using let| split across two lines is treated as two statements. +info: | + Lexical declarations may not declare a binding named "let". +flags: [noStrict] +features: [explicit-resource-management] +---*/ + +{ + using + let = "irrelevant initializer"; + + assert(typeof let === "string"); + var using, let; +} diff --git a/test/language/statements/using/syntax/using-for-statement.js b/test/language/statements/using/syntax/using-for-statement.js new file mode 100644 index 00000000000..982990ed50e --- /dev/null +++ b/test/language/statements/using/syntax/using-for-statement.js @@ -0,0 +1,14 @@ +// Copyright (C) 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-for-statement +description: > + using: 'for (using x = ' and 'for (using of =' are interpreted as for loop +features: [explicit-resource-management] +---*/ + +for (using x = null;;) break; + +// 'using of' lookahead restriction only applies to 'for-of'/'for-await-of'. In 'for' statement it is +// handled similar to `for (let of = null;;)`: +for (using of = null;;) break; diff --git a/test/language/statements/using/syntax/using-for-using-of-of.js b/test/language/statements/using/syntax/using-for-using-of-of.js new file mode 100644 index 00000000000..43229a56a45 --- /dev/null +++ b/test/language/statements/using/syntax/using-for-using-of-of.js @@ -0,0 +1,22 @@ +// Copyright (C) 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-for-in-and-for-of-statements +description: > + using: 'for (using of' is always interpreted as identifier +features: [explicit-resource-management] +---*/ + +var using, of = [[9], [8], [7]], result = []; +for (using of of [0, 1, 2]) { + // ^^^^^ ^^^^^^^^^^^^ + // | | + // | interpreted as element access `of[2]` + // | + // interpreted as identifier named `using` + + result.push(using); +} + +asserts.sameValue(result.length, 1); +asserts.sameValue(result[0], 7); diff --git a/test/language/statements/using/syntax/using-invalid-arraybindingpattern-after-bindingidentifier.js b/test/language/statements/using/syntax/using-invalid-arraybindingpattern-after-bindingidentifier.js new file mode 100644 index 00000000000..1268bc3f388 --- /dev/null +++ b/test/language/statements/using/syntax/using-invalid-arraybindingpattern-after-bindingidentifier.js @@ -0,0 +1,18 @@ +// Copyright (C) 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-let-const-using-and-await-using-declarations +description: > + 'using' does not allow ArrayBindingPattern in lexical bindings, even after a valid lexical binding +negative: + phase: parse + type: SyntaxError +features: [explicit-resource-management] +---*/ + +$DONOTEVALUATE(); + +{ + using x = null, [] = null; +} diff --git a/test/language/statements/using/syntax/using-invalid-arraybindingpattern-does-not-break-element-access.js b/test/language/statements/using/syntax/using-invalid-arraybindingpattern-does-not-break-element-access.js new file mode 100644 index 00000000000..91fed4c6793 --- /dev/null +++ b/test/language/statements/using/syntax/using-invalid-arraybindingpattern-does-not-break-element-access.js @@ -0,0 +1,15 @@ +// Copyright (C) 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-let-const-using-and-await-using-declarations +description: > + 'using' does not break existing element access +features: [explicit-resource-management] +---*/ + +var using = [], x = 0; + +{ + using[x] = null; +} diff --git a/test/language/statements/using/syntax/using-invalid-arraybindingpattern.js b/test/language/statements/using/syntax/using-invalid-arraybindingpattern.js new file mode 100644 index 00000000000..75c92e4b7f8 --- /dev/null +++ b/test/language/statements/using/syntax/using-invalid-arraybindingpattern.js @@ -0,0 +1,18 @@ +// Copyright (C) 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-let-const-using-and-await-using-declarations +description: > + 'using' does not allow ArrayBindingPattern in lexical bindings +negative: + phase: parse + type: SyntaxError +features: [explicit-resource-management] +---*/ + +$DONOTEVALUATE(); + +{ + using [] = null; +} diff --git a/test/language/statements/using/syntax/using-invalid-assignment-next-expression-for.js b/test/language/statements/using/syntax/using-invalid-assignment-next-expression-for.js new file mode 100644 index 00000000000..2eaff983702 --- /dev/null +++ b/test/language/statements/using/syntax/using-invalid-assignment-next-expression-for.js @@ -0,0 +1,14 @@ +// Copyright (C) 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-declarative-environment-records-setmutablebinding-n-v-s +description: > + using: invalid assignment in next expression. Since a `using` declaration introduces an immutable + binding, any attempt to change it results in a ReferenceError. +features: [explicit-resource-management] +---*/ + +assert.throws(ReferenceError, function() { + for (using i = 0; i < 1; i++) {} +}); diff --git a/test/language/statements/using/syntax/using-invalid-assignment-statement-body-for-of.js b/test/language/statements/using/syntax/using-invalid-assignment-statement-body-for-of.js new file mode 100644 index 00000000000..9c871c743f2 --- /dev/null +++ b/test/language/statements/using/syntax/using-invalid-assignment-statement-body-for-of.js @@ -0,0 +1,14 @@ +// Copyright (C) 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-declarative-environment-records-setmutablebinding-n-v-s +description: > + using: invalid assignment in Statement body. Since a `using` declaration introduces an immutable + binding, any attempt to change it results in a ReferenceError. +features: [explicit-resource-management] +---*/ + +assert.throws(ReferenceError, function() { + for (using x of [1, 2, 3]) { x++ } +}); diff --git a/test/language/statements/using/syntax/using-invalid-for-in.js b/test/language/statements/using/syntax/using-invalid-for-in.js new file mode 100644 index 00000000000..5dda622601d --- /dev/null +++ b/test/language/statements/using/syntax/using-invalid-for-in.js @@ -0,0 +1,14 @@ +// Copyright (C) 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-for-in-and-for-of-statements +description: > + using: not allowed in for..in +negative: + phase: parse + type: SyntaxError +features: [explicit-resource-management] +---*/ + +$DONOTEVALUATE(); +for (using x in [1, 2, 3]) { } diff --git a/test/language/statements/using/syntax/using-invalid-objectbindingpattern-after-bindingidentifier.js b/test/language/statements/using/syntax/using-invalid-objectbindingpattern-after-bindingidentifier.js new file mode 100644 index 00000000000..95f2d99c25b --- /dev/null +++ b/test/language/statements/using/syntax/using-invalid-objectbindingpattern-after-bindingidentifier.js @@ -0,0 +1,18 @@ +// Copyright (C) 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-let-const-using-and-await-using-declarations +description: > + 'using' does not allow ObjectBindingPattern in lexical bindings, even after a valid lexical binding +negative: + phase: parse + type: SyntaxError +features: [explicit-resource-management] +---*/ + +$DONOTEVALUATE(); + +{ + using x = null, {} = null; +} diff --git a/test/language/statements/using/syntax/using-invalid-objectbindingpattern.js b/test/language/statements/using/syntax/using-invalid-objectbindingpattern.js new file mode 100644 index 00000000000..f4e2f3459a1 --- /dev/null +++ b/test/language/statements/using/syntax/using-invalid-objectbindingpattern.js @@ -0,0 +1,18 @@ +// Copyright (C) 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-let-const-using-and-await-using-declarations +description: > + 'using' does not allow ObjectBindingPattern in lexical bindings +negative: + phase: parse + type: SyntaxError +features: [explicit-resource-management] +---*/ + +$DONOTEVALUATE(); + +{ + using {} = null; +} diff --git a/test/language/statements/using/syntax/using-not-allowed-at-top-level-of-eval.js b/test/language/statements/using/syntax/using-not-allowed-at-top-level-of-eval.js new file mode 100644 index 00000000000..8d02adc3b83 --- /dev/null +++ b/test/language/statements/using/syntax/using-not-allowed-at-top-level-of-eval.js @@ -0,0 +1,20 @@ +// Copyright (C) 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-let-const-using-and-await-using-declarations-static-semantics-early-errors +description: > + using declarations not allowed at the top level of eval. Note that Eval parses text using the Script goal. +info: | + UsingDeclaration : using BindingList ; + + - It is a Syntax Error if the goal symbol is Script and UsingDeclaration is not contained, either directly or + indirectly, within a Block, ForStatement, ForInOfStatement, FunctionBody, GeneratorBody, + AsyncGeneratorBody, AsyncFunctionBody, ClassStaticBlockBody, or ClassBody. + +features: [explicit-resource-management] +---*/ + +assert.throws(SyntaxError, function() { + eval('using x = null;') +}); diff --git a/test/language/statements/using/syntax/using-not-allowed-at-top-level-of-script.js b/test/language/statements/using/syntax/using-not-allowed-at-top-level-of-script.js new file mode 100644 index 00000000000..b90dfd59944 --- /dev/null +++ b/test/language/statements/using/syntax/using-not-allowed-at-top-level-of-script.js @@ -0,0 +1,22 @@ +// Copyright (C) 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-let-const-using-and-await-using-declarations-static-semantics-early-errors +description: > + using declarations not allowed at the top level of a Script +info: | + UsingDeclaration : using BindingList ; + + - It is a Syntax Error if the goal symbol is Script and UsingDeclaration is not contained, either directly or + indirectly, within a Block, ForStatement, ForInOfStatement, FunctionBody, GeneratorBody, + AsyncGeneratorBody, AsyncFunctionBody, ClassStaticBlockBody, or ClassBody. + +negative: + phase: parse + type: SyntaxError +features: [explicit-resource-management] +---*/ + +$DONOTEVALUATE(); +using x = null; diff --git a/test/language/statements/using/syntax/using-outer-inner-using-bindings.js b/test/language/statements/using/syntax/using-outer-inner-using-bindings.js new file mode 100644 index 00000000000..be474db608f --- /dev/null +++ b/test/language/statements/using/syntax/using-outer-inner-using-bindings.js @@ -0,0 +1,29 @@ +// Copyright (C) 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-runtime-semantics-fordeclarationbindinginstantiation +description: > + outer using binding unchanged by for-loop using binding +features: [explicit-resource-management] +---*/ + +const outer_x = { [Symbol.dispose]() {} }; +const outer_y = { [Symbol.dispose]() {} }; +const inner_x = { [Symbol.dispose]() {} }; +const inner_y = { [Symbol.dispose]() {} }; + +{ + using x = outer_x; + using y = outer_y; + var i = 0; + + for (using x = inner_x; i < 1; i++) { + using y = inner_y; + + assert.sameValue(x, inner_x); + assert.sameValue(y, inner_y); + } + assert.sameValue(x, outer_x); + assert.sameValue(y, outer_y); +} diff --git a/test/language/statements/using/syntax/using.js b/test/language/statements/using/syntax/using.js new file mode 100644 index 00000000000..7d591eb457f --- /dev/null +++ b/test/language/statements/using/syntax/using.js @@ -0,0 +1,25 @@ +// Copyright (C) 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-let-const-using-and-await-using-declarations +description: > + module and block scope using +flags: [module] +features: [explicit-resource-management] +---*/ + +using z = null; + +// Block local +{ + using z = undefined; +} + +assert.sameValue(z, null); + +if (true) { + const obj = { [Symbol.dispose]() { } }; + using z = obj; + assert.sameValue(z, obj); +} diff --git a/test/language/statements/using/syntax/with-initializer-case-expression-statement-list.js b/test/language/statements/using/syntax/with-initializer-case-expression-statement-list.js new file mode 100644 index 00000000000..3b6b4b2a23b --- /dev/null +++ b/test/language/statements/using/syntax/with-initializer-case-expression-statement-list.js @@ -0,0 +1,19 @@ +// Copyright (C) 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-let-const-using-and-await-using-declarations-static-semantics-early-errors +description: > + using declarations with initialisers in statement positions: + case Expression : StatementList +info: | + AwaitUsingDeclaration : CoverAwaitExpressionAndAwaitUsingDeclarationHead BindingList ; + - It is a Syntax Error if AwaitUsingDeclaration is contained directly within the StatementList of either a CaseClause or + DefaultClause. +negative: + phase: parse + type: SyntaxError +features: [explicit-resource-management] +---*/ +$DONOTEVALUATE(); +switch (true) { case true: using x = null; } diff --git a/test/language/statements/using/syntax/with-initializer-default-statement-list.js b/test/language/statements/using/syntax/with-initializer-default-statement-list.js new file mode 100644 index 00000000000..4b62382830a --- /dev/null +++ b/test/language/statements/using/syntax/with-initializer-default-statement-list.js @@ -0,0 +1,18 @@ +// Copyright (C) 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-let-const-using-and-await-using-declarations-static-semantics-early-errors +description: > + using declarations with initialisers in statement positions: + default : StatementList +info: | + AwaitUsingDeclaration : CoverAwaitExpressionAndAwaitUsingDeclarationHead BindingList ; + + - It is a Syntax Error if AwaitUsingDeclaration is contained directly within the StatementList of either a CaseClause or + DefaultClause. + +features: [explicit-resource-management] +---*/ +$DONOTEVALUATE(); +switch (true) { default: using x = null; } diff --git a/test/language/statements/using/syntax/with-initializer-do-statement-while-expression.js b/test/language/statements/using/syntax/with-initializer-do-statement-while-expression.js new file mode 100644 index 00000000000..e4bf454b440 --- /dev/null +++ b/test/language/statements/using/syntax/with-initializer-do-statement-while-expression.js @@ -0,0 +1,16 @@ +// Copyright (C) 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-do-while-statement +description: > + using declarations with initialisers in statement positions: + do Statement while ( Expression ) +negative: + phase: parse + type: SyntaxError +features: [explicit-resource-management] +---*/ + +$DONOTEVALUATE(); +do using x = 1; while (false) diff --git a/test/language/statements/using/syntax/with-initializer-for-statement.js b/test/language/statements/using/syntax/with-initializer-for-statement.js new file mode 100644 index 00000000000..1b960e0948a --- /dev/null +++ b/test/language/statements/using/syntax/with-initializer-for-statement.js @@ -0,0 +1,16 @@ +// Copyright (C) 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-for-statement +description: > + using declarations with initialisers in statement positions: + for (;;) Statement +negative: + phase: parse + type: SyntaxError +features: [explicit-resource-management] +---*/ + +$DONOTEVALUATE(); +for (;false;) using x = null; diff --git a/test/language/statements/using/syntax/with-initializer-if-expression-statement-else-statement.js b/test/language/statements/using/syntax/with-initializer-if-expression-statement-else-statement.js new file mode 100644 index 00000000000..26c1adfe9cf --- /dev/null +++ b/test/language/statements/using/syntax/with-initializer-if-expression-statement-else-statement.js @@ -0,0 +1,16 @@ +// Copyright (C) 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-if-statement +description: > + using declarations with initialisers in statement positions: + if ( Expression ) Statement else Statement +negative: + phase: parse + type: SyntaxError +features: [explicit-resource-management] +---*/ + +$DONOTEVALUATE(); +if (true) {} else using x = null; diff --git a/test/language/statements/using/syntax/with-initializer-if-expression-statement.js b/test/language/statements/using/syntax/with-initializer-if-expression-statement.js new file mode 100644 index 00000000000..0271df4327d --- /dev/null +++ b/test/language/statements/using/syntax/with-initializer-if-expression-statement.js @@ -0,0 +1,16 @@ +// Copyright (C) 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-if-statement +description: > + using declarations with initialisers in statement positions: + if ( Expression ) Statement +negative: + phase: parse + type: SyntaxError +features: [explicit-resource-management] +---*/ + +$DONOTEVALUATE(); +if (true) using x = null; diff --git a/test/language/statements/using/syntax/with-initializer-label-statement.js b/test/language/statements/using/syntax/with-initializer-label-statement.js new file mode 100644 index 00000000000..cef0b3f2eda --- /dev/null +++ b/test/language/statements/using/syntax/with-initializer-label-statement.js @@ -0,0 +1,16 @@ +// Copyright (C) 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-labelled-statements +description: > + using declarations with initialisers in statement positions: + label: Statement +negative: + phase: parse + type: SyntaxError +features: [explicit-resource-management] +---*/ + +$DONOTEVALUATE(); +label: using x = null; diff --git a/test/language/statements/using/syntax/with-initializer-while-expression-statement.js b/test/language/statements/using/syntax/with-initializer-while-expression-statement.js new file mode 100644 index 00000000000..a450b157938 --- /dev/null +++ b/test/language/statements/using/syntax/with-initializer-while-expression-statement.js @@ -0,0 +1,16 @@ +// Copyright (C) 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-while-statement +description: > + using declarations with initialisers in statement positions: + while ( Expression ) Statement +negative: + phase: parse + type: SyntaxError +features: [explicit-resource-management] +---*/ + +$DONOTEVALUATE(); +while (false) using x = null; diff --git a/test/language/statements/using/syntax/without-initializer-do-statement-while-expression.js b/test/language/statements/using/syntax/without-initializer-do-statement-while-expression.js new file mode 100644 index 00000000000..85e9ad9428a --- /dev/null +++ b/test/language/statements/using/syntax/without-initializer-do-statement-while-expression.js @@ -0,0 +1,16 @@ +// Copyright (C) 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-do-while-statement +description: > + using declarations without initialisers in statement positions: + do Statement while ( Expression ) +negative: + phase: parse + type: SyntaxError +features: [explicit-resource-management] +---*/ + +$DONOTEVALUATE(); +do using x; while (false) diff --git a/test/language/statements/using/syntax/without-initializer-for-statement.js b/test/language/statements/using/syntax/without-initializer-for-statement.js new file mode 100644 index 00000000000..6a2c72e8e70 --- /dev/null +++ b/test/language/statements/using/syntax/without-initializer-for-statement.js @@ -0,0 +1,16 @@ +// Copyright (C) 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-for-statement +description: > + using declarations without initialisers in statement positions: + for ( ;;) Statement +negative: + phase: parse + type: SyntaxError +features: [explicit-resource-management] +---*/ + +$DONOTEVALUATE(); +for (;false;) using x; diff --git a/test/language/statements/using/syntax/without-initializer-if-expression-statement-else-statement.js b/test/language/statements/using/syntax/without-initializer-if-expression-statement-else-statement.js new file mode 100644 index 00000000000..e6a6ffeafa1 --- /dev/null +++ b/test/language/statements/using/syntax/without-initializer-if-expression-statement-else-statement.js @@ -0,0 +1,16 @@ +// Copyright (C) 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-if-statement +description: > + using declarations without initialisers in statement positions: + if ( Expression ) Statement else Statement +negative: + phase: parse + type: SyntaxError +features: [explicit-resource-management] +---*/ + +$DONOTEVALUATE(); +if (true) {} else using x; diff --git a/test/language/statements/using/syntax/without-initializer-if-expression-statement.js b/test/language/statements/using/syntax/without-initializer-if-expression-statement.js new file mode 100644 index 00000000000..132b78bfae3 --- /dev/null +++ b/test/language/statements/using/syntax/without-initializer-if-expression-statement.js @@ -0,0 +1,16 @@ +// Copyright (C) 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-if-statement +description: > + using declarations without initialisers in statement positions: + if ( Expression ) Statement +negative: + phase: parse + type: SyntaxError +features: [explicit-resource-management] +---*/ + +$DONOTEVALUATE(); +if (true) using x; diff --git a/test/language/statements/using/syntax/without-initializer-label-statement.js b/test/language/statements/using/syntax/without-initializer-label-statement.js new file mode 100644 index 00000000000..7ce1c4b362c --- /dev/null +++ b/test/language/statements/using/syntax/without-initializer-label-statement.js @@ -0,0 +1,16 @@ +// Copyright (C) 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-labelled-statements +description: > + using declarations without initialisers in statement positions: + label: Statement +negative: + phase: parse + type: SyntaxError +features: [explicit-resource-management] +---*/ + +$DONOTEVALUATE(); +label: using x; diff --git a/test/language/statements/using/syntax/without-initializer-while-expression-statement.js b/test/language/statements/using/syntax/without-initializer-while-expression-statement.js new file mode 100644 index 00000000000..973612d49e4 --- /dev/null +++ b/test/language/statements/using/syntax/without-initializer-while-expression-statement.js @@ -0,0 +1,16 @@ +// Copyright (C) 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-while-statement +description: > + using declarations without initialisers in statement positions: + while ( Expression ) Statement +negative: + phase: parse + type: SyntaxError +features: [explicit-resource-management] +---*/ + +$DONOTEVALUATE(); +while (false) using x;