-
Notifications
You must be signed in to change notification settings - Fork 471
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for "Class Static Init. Blocks" proposal (#2968)
* Add tests for "Class Static Init. Blocks" proposal This proposal is currently at "stage 3" in TC39's standardization process. * fixup! Add tests for "Class Static Init. Blocks" proposal * Correct identifier reference * Update tests for grammar * Update tests for identifiers * Add tests for scope derivation
- Loading branch information
1 parent
f1f3a2d
commit afe217b
Showing
64 changed files
with
1,582 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
18 changes: 18 additions & 0 deletions
18
test/language/expressions/arrow-function/static-init-await-binding.js
This file contains 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) 2021 the V8 project authors. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
/*--- | ||
esid: sec-class-definitions-static-semantics-early-errors | ||
description: The `await` keyword is disallowed in the BindingIdentifier position | ||
features: [class-static-block] | ||
negative: | ||
phase: parse | ||
type: SyntaxError | ||
---*/ | ||
|
||
$DONOTEVALUATE(); | ||
|
||
class C { | ||
static { | ||
(await => 0); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
test/language/expressions/arrow-function/static-init-await-reference.js
This file contains 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) 2021 the V8 project authors. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
/*--- | ||
esid: sec-class-definitions-static-semantics-early-errors | ||
description: The `await` keyword is disallowed in the IdentifierReference position | ||
features: [class-static-block] | ||
negative: | ||
phase: parse | ||
type: SyntaxError | ||
---*/ | ||
|
||
$DONOTEVALUATE(); | ||
|
||
class C { | ||
static { | ||
((x = await) => 0); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
test/language/expressions/class/static-init-await-binding.js
This file contains 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,23 @@ | ||
// Copyright (C) 2021 the V8 project authors. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
/*--- | ||
esid: sec-class-definitions-static-semantics-early-errors | ||
description: The `await` keyword is disallowed as a BindingIdentifier | ||
info: | | ||
ClassStaticBlockBody : ClassStaticBlockStatementList | ||
[...] | ||
- It is a Syntax Error if ContainsAwait of ClassStaticBlockStatementList is true. | ||
features: [class-static-block] | ||
negative: | ||
phase: parse | ||
type: SyntaxError | ||
---*/ | ||
|
||
$DONOTEVALUATE(); | ||
|
||
class C { | ||
static { | ||
(class await {}); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
test/language/expressions/class/static-init-await-reference.js
This file contains 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,28 @@ | ||
// Copyright (C) 2021 the V8 project authors. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
/*--- | ||
esid: sec-class-definitions-static-semantics-early-errors | ||
description: The `await` keyword is interpreted as a IdentifierReference in method parameter lists | ||
info: | | ||
ClassStaticBlockBody : ClassStaticBlockStatementList | ||
[...] | ||
- It is a Syntax Error if ContainsAwait of ClassStaticBlockStatementList is true. | ||
features: [class-static-block] | ||
---*/ | ||
|
||
var await = 0; | ||
var fromParam, fromBody; | ||
|
||
class C { | ||
static { | ||
new (class { | ||
constructor(x = fromParam = await) { | ||
fromBody = await; | ||
} | ||
}); | ||
} | ||
} | ||
|
||
assert.sameValue(fromParam, 0, 'from parameter'); | ||
assert.sameValue(fromBody, 0, 'from body'); |
18 changes: 18 additions & 0 deletions
18
test/language/expressions/function/static-init-await-binding.js
This file contains 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) 2021 the V8 project authors. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
/*--- | ||
esid: sec-class-definitions-static-semantics-early-errors | ||
description: The `await` keyword is interpreted as an IdentifierReference within function expressions | ||
info: | | ||
ClassStaticBlockBody : ClassStaticBlockStatementList | ||
[...] | ||
- It is a Syntax Error if ContainsAwait of ClassStaticBlockStatementList is true. | ||
features: [class-static-block] | ||
---*/ | ||
|
||
class C { | ||
static { | ||
(function await(await) {}); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
test/language/expressions/function/static-init-await-reference.js
This file contains 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,26 @@ | ||
// Copyright (C) 2021 the V8 project authors. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
/*--- | ||
esid: sec-class-definitions-static-semantics-early-errors | ||
description: The `await` keyword is interpreted as an IdentifierReference within function expressions | ||
info: | | ||
ClassStaticBlockBody : ClassStaticBlockStatementList | ||
[...] | ||
- It is a Syntax Error if ContainsAwait of ClassStaticBlockStatementList is true. | ||
features: [class-static-block] | ||
---*/ | ||
|
||
var await = 0; | ||
var fromParam, fromBody; | ||
|
||
class C { | ||
static { | ||
(function (x = fromParam = await) { | ||
fromBody = await; | ||
})(); | ||
} | ||
} | ||
|
||
assert.sameValue(fromParam, 0, 'from parameter'); | ||
assert.sameValue(fromBody, 0, 'from body'); |
18 changes: 18 additions & 0 deletions
18
test/language/expressions/generators/static-init-await-binding.js
This file contains 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) 2021 the V8 project authors. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
/*--- | ||
esid: sec-class-definitions-static-semantics-early-errors | ||
description: The `await` keyword is interpreted as an Identifier within generator function expressions | ||
info: | | ||
ClassStaticBlockBody : ClassStaticBlockStatementList | ||
[...] | ||
- It is a Syntax Error if ContainsAwait of ClassStaticBlockStatementList is true. | ||
features: [class-static-block] | ||
---*/ | ||
|
||
class C { | ||
static { | ||
(function * await (await) {}); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
test/language/expressions/generators/static-init-await-reference.js
This file contains 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,26 @@ | ||
// Copyright (C) 2021 the V8 project authors. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
/*--- | ||
esid: sec-class-definitions-static-semantics-early-errors | ||
description: The `await` keyword is interpreted as an Identifier within generator function expressions | ||
info: | | ||
ClassStaticBlockBody : ClassStaticBlockStatementList | ||
[...] | ||
- It is a Syntax Error if ContainsAwait of ClassStaticBlockStatementList is true. | ||
features: [class-static-block] | ||
---*/ | ||
|
||
var await = 0; | ||
var fromParam, fromBody; | ||
|
||
class C { | ||
static { | ||
(function * (x = fromParam = await) { | ||
fromBody = await; | ||
})().next(); | ||
} | ||
} | ||
|
||
assert.sameValue(fromParam, 0, 'from parameter'); | ||
assert.sameValue(fromBody, 0, 'from body'); |
22 changes: 22 additions & 0 deletions
22
test/language/expressions/object/ident-name-prop-name-literal-await-static-init.js
This file contains 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) 2021 the V8 project authors. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
/*--- | ||
esid: sec-class-definitions-static-semantics-early-errors | ||
description: The restriction on `await` does not apply to IdentifierName | ||
info: | | ||
BindingIdentifier : Identifier | ||
[...] | ||
- It is a Syntax Error if the code matched by this production is nested, | ||
directly or indirectly (but not crossing function or static initialization | ||
block boundaries), within a ClassStaticBlock and the StringValue of | ||
Identifier is "await". | ||
features: [class-static-block] | ||
---*/ | ||
|
||
class C { | ||
static { | ||
({ await: 0 }); | ||
} | ||
} | ||
|
26 changes: 26 additions & 0 deletions
26
test/language/expressions/object/identifier-shorthand-static-init-await-invalid.js
This file contains 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,26 @@ | ||
// Copyright (C) 2021 the V8 project authors. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
/*--- | ||
esid: sec-class-definitions-static-semantics-early-errors | ||
description: IdentifierReference may not be `await` within class static blocks | ||
info: | | ||
IdentifierReference : Identifier | ||
- It is a Syntax Error if the code matched by this production is nested, | ||
directly or indirectly (but not crossing function or static initialization | ||
block boundaries), within a ClassStaticBlock and the StringValue of | ||
Identifier is "arguments" or "await". | ||
negative: | ||
phase: parse | ||
type: SyntaxError | ||
features: [class-static-block] | ||
---*/ | ||
|
||
$DONOTEVALUATE(); | ||
|
||
class C { | ||
static { | ||
({ await }); | ||
} | ||
} | ||
|
18 changes: 18 additions & 0 deletions
18
test/language/expressions/object/identifier-shorthand-static-init-await-valid.js
This file contains 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) 2021 the V8 project authors. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
/*--- | ||
esid: sec-class-definitions-static-semantics-early-errors | ||
description: The `await` keyword is interpreted as an identifier within the body of arrow functions | ||
info: | | ||
ClassStaticBlockBody : ClassStaticBlockStatementList | ||
[...] | ||
- It is a Syntax Error if ContainsAwait of ClassStaticBlockStatementList is true. | ||
features: [class-static-block] | ||
---*/ | ||
|
||
class C { | ||
static { | ||
(() => ({ await })); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
test/language/expressions/object/method-definition/static-init-await-binding-accessor.js
This file contains 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) 2021 the V8 project authors. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
/*--- | ||
esid: sec-class-definitions-static-semantics-early-errors | ||
description: The `await` keyword is interpreted as an identifier within the body of accessor methods | ||
info: | | ||
ClassStaticBlockBody : ClassStaticBlockStatementList | ||
[...] | ||
- It is a Syntax Error if ContainsAwait of ClassStaticBlockStatementList is true. | ||
features: [class-static-block] | ||
---*/ | ||
|
||
class C { | ||
static { | ||
({set accessor(await) {}}); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
test/language/expressions/object/method-definition/static-init-await-binding-generator.js
This file contains 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) 2021 the V8 project authors. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
/*--- | ||
esid: sec-class-definitions-static-semantics-early-errors | ||
description: The `await` keyword is interpreted as an identifier within the parameter list of generator methods | ||
info: | | ||
ClassStaticBlockBody : ClassStaticBlockStatementList | ||
[...] | ||
- It is a Syntax Error if ContainsAwait of ClassStaticBlockStatementList is true. | ||
features: [class-static-block] | ||
---*/ | ||
|
||
class C { | ||
static { | ||
({*method(await) {}}); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
test/language/expressions/object/method-definition/static-init-await-binding-normal.js
This file contains 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) 2021 the V8 project authors. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
/*--- | ||
esid: sec-class-definitions-static-semantics-early-errors | ||
description: The `await` keyword is interpreted as an identifier within the parameter list of methods | ||
info: | | ||
ClassStaticBlockBody : ClassStaticBlockStatementList | ||
[...] | ||
- It is a Syntax Error if ContainsAwait of ClassStaticBlockStatementList is true. | ||
features: [class-static-block] | ||
---*/ | ||
|
||
class C { | ||
static { | ||
({method(await) {}}); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
test/language/expressions/object/method-definition/static-init-await-reference-accessor.js
This file contains 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,28 @@ | ||
// Copyright (C) 2021 the V8 project authors. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
/*--- | ||
esid: sec-class-definitions-static-semantics-early-errors | ||
description: The `await` keyword is interpreted as an identifier within accessor methods | ||
info: | | ||
ClassStaticBlockBody : ClassStaticBlockStatementList | ||
[...] | ||
- It is a Syntax Error if ContainsAwait of ClassStaticBlockStatementList is true. | ||
features: [class-static-block] | ||
---*/ | ||
|
||
var await = 0; | ||
var fromParam, fromBody; | ||
|
||
class C { | ||
static { | ||
({ | ||
set accessor(x = fromParam = await) { | ||
fromBody = await; | ||
} | ||
}).accessor = undefined; | ||
} | ||
} | ||
|
||
assert.sameValue(fromParam, 0, 'from parameter'); | ||
assert.sameValue(fromBody, 0, 'from body'); |
28 changes: 28 additions & 0 deletions
28
test/language/expressions/object/method-definition/static-init-await-reference-generator.js
This file contains 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,28 @@ | ||
// Copyright (C) 2021 the V8 project authors. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
/*--- | ||
esid: sec-class-definitions-static-semantics-early-errors | ||
description: The `await` keyword is interpreted as an identifier within generator methods | ||
info: | | ||
ClassStaticBlockBody : ClassStaticBlockStatementList | ||
[...] | ||
- It is a Syntax Error if ContainsAwait of ClassStaticBlockStatementList is true. | ||
features: [class-static-block] | ||
---*/ | ||
|
||
var await = 0; | ||
var fromParam, fromBody; | ||
|
||
class C { | ||
static { | ||
({ | ||
*method(x = fromParam = await) { | ||
fromBody = await; | ||
} | ||
}).method().next(); | ||
} | ||
} | ||
|
||
assert.sameValue(fromParam, 0, 'from parameter'); | ||
assert.sameValue(fromBody, 0, 'from body'); |
Oops, something went wrong.