-
Notifications
You must be signed in to change notification settings - Fork 488
[explicit-resource-management] Add remaining tests specific to using statement syntax #4483
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rbuckton
wants to merge
3
commits into
tc39:main
Choose a base branch
from
rbuckton:explicit-resource-management-using-syntax
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
...ents/using/syntax/block-scope-syntax-using-declarations-mixed-with-without-initializer.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright (C) 2023 Ron Buckton. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: pending | ||
description: > | ||
using declarations mixed: with, without initializer | ||
negative: | ||
phase: parse | ||
type: SyntaxError | ||
features: [explicit-resource-management] | ||
---*/ | ||
|
||
$DONOTEVALUATE(); | ||
{ | ||
using x = null, y; | ||
} |
17 changes: 17 additions & 0 deletions
17
...ents/using/syntax/block-scope-syntax-using-declarations-mixed-without-with-initializer.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright (C) 2023 Ron Buckton. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: pending | ||
description: > | ||
using declarations mixed: without, with initializer | ||
negative: | ||
phase: parse | ||
type: SyntaxError | ||
features: [explicit-resource-management] | ||
---*/ | ||
|
||
$DONOTEVALUATE(); | ||
{ | ||
using x, y = null; | ||
} |
17 changes: 17 additions & 0 deletions
17
...uage/statements/using/syntax/block-scope-syntax-using-declarations-without-initializer.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright (C) 2023 Ron Buckton. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: pending | ||
description: > | ||
using declarations without initializer | ||
negative: | ||
phase: parse | ||
type: SyntaxError | ||
features: [explicit-resource-management] | ||
---*/ | ||
|
||
$DONOTEVALUATE(); | ||
{ | ||
using x; | ||
} |
19 changes: 19 additions & 0 deletions
19
test/language/statements/using/syntax/using-allowed-at-top-level-of-module.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: pending | ||
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, CaseBlock, ForStatement, ForInOfStatement, FunctionBody, GeneratorBody, | ||
AsyncGeneratorBody, AsyncFunctionBody, ClassStaticBlockBody, or ClassBody. | ||
|
||
flags: [module] | ||
features: [explicit-resource-management] | ||
---*/ | ||
|
||
using x = null; |
12 changes: 12 additions & 0 deletions
12
test/language/statements/using/syntax/using-allows-bindingidentifier.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: pending | ||
description: > | ||
'using' allows BindingIdentifier in lexical bindings | ||
features: [explicit-resource-management] | ||
---*/ | ||
{ | ||
using x = null; | ||
} |
13 changes: 13 additions & 0 deletions
13
test/language/statements/using/syntax/using-allows-multiple-bindings.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: pending | ||
description: > | ||
'using' allows multiple lexical bindings | ||
features: [explicit-resource-management] | ||
---*/ | ||
|
||
{ | ||
using x = null, y = null; | ||
} |
20 changes: 20 additions & 0 deletions
20
test/language/statements/using/syntax/using-declaring-let-split-across-two-lines.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: pending | ||
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; | ||
} |
14 changes: 14 additions & 0 deletions
14
test/language/statements/using/syntax/using-for-statement.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright (C) 2011 the V8 project authors. 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; |
22 changes: 22 additions & 0 deletions
22
test/language/statements/using/syntax/using-for-using-of-of.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright (C) 2011 the V8 project authors. 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); |
18 changes: 18 additions & 0 deletions
18
...uage/statements/using/syntax/using-invalid-arraybindingpattern-after-bindingidentifier.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: pending | ||
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; | ||
} |
15 changes: 15 additions & 0 deletions
15
...tatements/using/syntax/using-invalid-arraybindingpattern-does-not-break-element-access.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: pending | ||
description: > | ||
'using' does not break existing element access | ||
features: [explicit-resource-management] | ||
---*/ | ||
|
||
var using = [], x = 0; | ||
|
||
{ | ||
using[x] = null; | ||
} |
18 changes: 18 additions & 0 deletions
18
test/language/statements/using/syntax/using-invalid-arraybindingpattern.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: pending | ||
description: > | ||
'using' does not allow ArrayBindingPattern in lexical bindings | ||
negative: | ||
phase: parse | ||
type: SyntaxError | ||
features: [explicit-resource-management] | ||
---*/ | ||
|
||
$DONOTEVALUATE(); | ||
|
||
{ | ||
using [] = null; | ||
} |
13 changes: 13 additions & 0 deletions
13
test/language/statements/using/syntax/using-invalid-assignment-next-expression-for.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: pending | ||
description: > | ||
using: invalid assignment in next expression | ||
features: [explicit-resource-management] | ||
---*/ | ||
|
||
assert.throws(TypeError, function() { | ||
for (using i = 0; i < 1; i++) {} | ||
}); |
13 changes: 13 additions & 0 deletions
13
test/language/statements/using/syntax/using-invalid-assignment-statement-body-for-of.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: pending | ||
description: > | ||
using: invalid assignment in Statement body | ||
features: [explicit-resource-management] | ||
---*/ | ||
|
||
assert.throws(TypeError, function() { | ||
for (using x of [1, 2, 3]) { x++ } | ||
}); |
14 changes: 14 additions & 0 deletions
14
test/language/statements/using/syntax/using-invalid-for-in.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright (C) 2011 the V8 project authors. 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]) { } |
18 changes: 18 additions & 0 deletions
18
...age/statements/using/syntax/using-invalid-objectbindingpattern-after-bindingidentifier.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: pending | ||
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; | ||
} |
18 changes: 18 additions & 0 deletions
18
test/language/statements/using/syntax/using-invalid-objectbindingpattern.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: pending | ||
description: > | ||
'using' does not allow ObjectBindingPattern in lexical bindings | ||
negative: | ||
phase: parse | ||
type: SyntaxError | ||
features: [explicit-resource-management] | ||
---*/ | ||
|
||
$DONOTEVALUATE(); | ||
|
||
{ | ||
using {} = null; | ||
} |
20 changes: 20 additions & 0 deletions
20
test/language/statements/using/syntax/using-not-allowed-at-top-level-of-eval.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: pending | ||
description: > | ||
using declarations not allowed at the top level of eval | ||
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, CaseBlock, ForStatement, ForInOfStatement, FunctionBody, GeneratorBody, | ||
AsyncGeneratorBody, AsyncFunctionBody, ClassStaticBlockBody, or ClassBody. | ||
|
||
features: [explicit-resource-management] | ||
---*/ | ||
|
||
assert.throws(SyntaxError, function() { | ||
eval('using x = null;') | ||
}); |
22 changes: 22 additions & 0 deletions
22
test/language/statements/using/syntax/using-not-allowed-at-top-level-of-script.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: pending | ||
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, CaseBlock, ForStatement, ForInOfStatement, FunctionBody, GeneratorBody, | ||
AsyncGeneratorBody, AsyncFunctionBody, ClassStaticBlockBody, or ClassBody. | ||
|
||
negative: | ||
phase: parse | ||
type: SyntaxError | ||
features: [explicit-resource-management] | ||
---*/ | ||
|
||
$DONOTEVALUATE(); | ||
using x = null; |
29 changes: 29 additions & 0 deletions
29
test/language/statements/using/syntax/using-outer-inner-using-bindings.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: pending | ||
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); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: pending | ||
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); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copy-paste error? (Check this in a few places)