mirror of
https://github.com/tc39/test262.git
synced 2025-07-23 14:04:51 +02:00
Add templates and cases for matchings of a StatementList
This commit is contained in:
parent
1dc78879d4
commit
c509173032
30
src/statementList/array-literal-with-item.case
Normal file
30
src/statementList/array-literal-with-item.case
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
// Copyright (C) 2019 Leo Balter. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
desc: Array Literal with items
|
||||||
|
template: default
|
||||||
|
info: |
|
||||||
|
Statement:
|
||||||
|
BlockStatement
|
||||||
|
VariableStatement
|
||||||
|
EmptyStatement
|
||||||
|
ExpressionStatement
|
||||||
|
...
|
||||||
|
|
||||||
|
ExpressionStatement:
|
||||||
|
[lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }]
|
||||||
|
Expression ;
|
||||||
|
|
||||||
|
ArrayLiteral[Yield, Await]:
|
||||||
|
[ Elision_opt ]
|
||||||
|
[ ElementList ]
|
||||||
|
[ ElementList , Elision_opt ]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
//- StatementListItem
|
||||||
|
[42];
|
||||||
|
//- EvalAssertions
|
||||||
|
assert.sameValue(Object.getPrototypeOf(result), Array.prototype);
|
||||||
|
assert.sameValue(result.length, 1);
|
||||||
|
assert.sameValue(result[0], 42);
|
29
src/statementList/array-literal.case
Normal file
29
src/statementList/array-literal.case
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
// Copyright (C) 2019 Leo Balter. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
desc: Array Literal
|
||||||
|
template: default
|
||||||
|
info: |
|
||||||
|
Statement:
|
||||||
|
BlockStatement
|
||||||
|
VariableStatement
|
||||||
|
EmptyStatement
|
||||||
|
ExpressionStatement
|
||||||
|
...
|
||||||
|
|
||||||
|
ExpressionStatement:
|
||||||
|
[lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }]
|
||||||
|
Expression ;
|
||||||
|
|
||||||
|
ArrayLiteral[Yield, Await]:
|
||||||
|
[ Elision_opt ]
|
||||||
|
[ ElementList ]
|
||||||
|
[ ElementList , Elision_opt ]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
//- StatementListItem
|
||||||
|
[];
|
||||||
|
//- EvalAssertions
|
||||||
|
assert.sameValue(Object.getPrototypeOf(result), Array.prototype);
|
||||||
|
assert.sameValue(result.length, 0);
|
38
src/statementList/arrow-function-assignment-expr.case
Normal file
38
src/statementList/arrow-function-assignment-expr.case
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
// Copyright (C) 2019 Leo Balter. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
desc: Arrow Function with an AssignmentExpression
|
||||||
|
template: default
|
||||||
|
info: |
|
||||||
|
Statement:
|
||||||
|
BlockStatement
|
||||||
|
VariableStatement
|
||||||
|
EmptyStatement
|
||||||
|
ExpressionStatement
|
||||||
|
...
|
||||||
|
|
||||||
|
ExpressionStatement:
|
||||||
|
[lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }]
|
||||||
|
Expression ;
|
||||||
|
|
||||||
|
...
|
||||||
|
|
||||||
|
AssignmentExpression:
|
||||||
|
ConditionalExpression
|
||||||
|
[+Yield]YieldExpression
|
||||||
|
ArrowFunction
|
||||||
|
|
||||||
|
ArrowFunction:
|
||||||
|
ArrowParameters [no LineTerminator here] => ConciseBody
|
||||||
|
|
||||||
|
ConciseBody:
|
||||||
|
[lookahead ≠ {] AssignmentExpression
|
||||||
|
{ FunctionBody }
|
||||||
|
features: [arrow-function]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
//- StatementListItem
|
||||||
|
() => 42;
|
||||||
|
//- EvalAssertions
|
||||||
|
assert.sameValue(result(), 42);
|
38
src/statementList/arrow-function-functionbody.case
Normal file
38
src/statementList/arrow-function-functionbody.case
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
// Copyright (C) 2019 Leo Balter. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
desc: Arrow Function with a Function Body
|
||||||
|
template: default
|
||||||
|
info: |
|
||||||
|
Statement:
|
||||||
|
BlockStatement
|
||||||
|
VariableStatement
|
||||||
|
EmptyStatement
|
||||||
|
ExpressionStatement
|
||||||
|
...
|
||||||
|
|
||||||
|
ExpressionStatement:
|
||||||
|
[lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }]
|
||||||
|
Expression ;
|
||||||
|
|
||||||
|
...
|
||||||
|
|
||||||
|
AssignmentExpression:
|
||||||
|
ConditionalExpression
|
||||||
|
[+Yield]YieldExpression
|
||||||
|
ArrowFunction
|
||||||
|
|
||||||
|
ArrowFunction:
|
||||||
|
ArrowParameters [no LineTerminator here] => ConciseBody
|
||||||
|
|
||||||
|
ConciseBody:
|
||||||
|
[lookahead ≠ {] AssignmentExpression
|
||||||
|
{ FunctionBody }
|
||||||
|
features: [arrow-function]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
//- StatementListItem
|
||||||
|
() => { return 42; };
|
||||||
|
//- EvalAssertions
|
||||||
|
assert.sameValue(result(), 42);
|
24
src/statementList/block-with-labels.case
Normal file
24
src/statementList/block-with-labels.case
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
// Copyright (C) 2019 Leo Balter. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
desc: Block with a label
|
||||||
|
template: default
|
||||||
|
info: |
|
||||||
|
Statement:
|
||||||
|
BlockStatement
|
||||||
|
VariableStatement
|
||||||
|
EmptyStatement
|
||||||
|
ExpressionStatement
|
||||||
|
...
|
||||||
|
|
||||||
|
// lookahead here prevents capturing an Object literal
|
||||||
|
ExpressionStatement:
|
||||||
|
[lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }]
|
||||||
|
Expression ;
|
||||||
|
---*/
|
||||||
|
|
||||||
|
//- StatementListItem
|
||||||
|
{x: 42};
|
||||||
|
//- EvalAssertions
|
||||||
|
assert.sameValue(result, 42, 'it does not evaluate to an Object with the property x');
|
26
src/statementList/block.case
Normal file
26
src/statementList/block.case
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
// Copyright (C) 2019 Leo Balter. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
desc: Block
|
||||||
|
template: default
|
||||||
|
info: |
|
||||||
|
Statement:
|
||||||
|
BlockStatement
|
||||||
|
VariableStatement
|
||||||
|
EmptyStatement
|
||||||
|
ExpressionStatement
|
||||||
|
...
|
||||||
|
|
||||||
|
// lookahead here prevents capturing an Object literal
|
||||||
|
ExpressionStatement:
|
||||||
|
[lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }]
|
||||||
|
Expression ;
|
||||||
|
---*/
|
||||||
|
|
||||||
|
//- StatementListItem
|
||||||
|
{}
|
||||||
|
//- EvalAssertions
|
||||||
|
assert.sameValue(result, undefined);
|
||||||
|
//- EvalAssertionsCompletion
|
||||||
|
assert.sameValue(result, expected);
|
28
src/statementList/default/block-with-statement.template
Normal file
28
src/statementList/default/block-with-statement.template
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// Copyright (C) 2019 Leo Balter. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
path: language/statementList/block-with-statment-
|
||||||
|
name: Valid syntax of StatementList starting with a BlockStatement
|
||||||
|
esid: prod-StatementList
|
||||||
|
info: |
|
||||||
|
StatementList:
|
||||||
|
StatementListItem
|
||||||
|
StatementList StatementListItem
|
||||||
|
|
||||||
|
StatementListItem:
|
||||||
|
Statement
|
||||||
|
Declaration
|
||||||
|
|
||||||
|
Statement:
|
||||||
|
BlockStatement
|
||||||
|
|
||||||
|
BlockStatement:
|
||||||
|
Block
|
||||||
|
|
||||||
|
Block:
|
||||||
|
{ StatementList_opt }
|
||||||
|
---*/
|
||||||
|
|
||||||
|
// length is a label!
|
||||||
|
{length: 3000}/*{ StatementListItem }*/;
|
27
src/statementList/default/block.template
Normal file
27
src/statementList/default/block.template
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
// Copyright (C) 2019 Leo Balter. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
path: language/statementList/block-
|
||||||
|
name: Valid syntax of StatementList starting with a BlockStatement
|
||||||
|
esid: prod-StatementList
|
||||||
|
info: |
|
||||||
|
StatementList:
|
||||||
|
StatementListItem
|
||||||
|
StatementList StatementListItem
|
||||||
|
|
||||||
|
StatementListItem:
|
||||||
|
Statement
|
||||||
|
Declaration
|
||||||
|
|
||||||
|
Statement:
|
||||||
|
BlockStatement
|
||||||
|
|
||||||
|
BlockStatement:
|
||||||
|
Block
|
||||||
|
|
||||||
|
Block:
|
||||||
|
{ StatementList_opt }
|
||||||
|
---*/
|
||||||
|
|
||||||
|
{}/*{ StatementListItem }*/;
|
22
src/statementList/default/class-declaration.template
Normal file
22
src/statementList/default/class-declaration.template
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// Copyright (C) 2019 Leo Balter. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
path: language/statementList/class-
|
||||||
|
name: Valid syntax of StatementList starting with a Class Declaration
|
||||||
|
esid: prod-StatementList
|
||||||
|
info: |
|
||||||
|
StatementList:
|
||||||
|
StatementListItem
|
||||||
|
StatementList StatementListItem
|
||||||
|
|
||||||
|
StatementListItem:
|
||||||
|
Statement
|
||||||
|
Declaration
|
||||||
|
|
||||||
|
Declaration:
|
||||||
|
ClassDeclaration
|
||||||
|
features: [class]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
class C {}/*{ StatementListItem }*/;
|
33
src/statementList/default/eval-block-with-statement.template
Normal file
33
src/statementList/default/eval-block-with-statement.template
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
// Copyright (C) 2019 Leo Balter. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
path: language/statementList/eval-block-with-statment-
|
||||||
|
name: Evaluate produciton of StatementList starting with a BlockStatement
|
||||||
|
esid: prod-StatementList
|
||||||
|
info: |
|
||||||
|
StatementList:
|
||||||
|
StatementListItem
|
||||||
|
StatementList StatementListItem
|
||||||
|
|
||||||
|
StatementListItem:
|
||||||
|
Statement
|
||||||
|
Declaration
|
||||||
|
|
||||||
|
Statement:
|
||||||
|
BlockStatement
|
||||||
|
|
||||||
|
BlockStatement:
|
||||||
|
Block
|
||||||
|
|
||||||
|
Block:
|
||||||
|
{ StatementList_opt }
|
||||||
|
---*/
|
||||||
|
|
||||||
|
// length is a label!
|
||||||
|
var result = eval('{length: 3000}/*{ StatementListItem }*/;');
|
||||||
|
|
||||||
|
// Reuse this value for items with empty completions
|
||||||
|
var expected = 3000;
|
||||||
|
|
||||||
|
/*{ EvalAssertionsCompletion }*/
|
29
src/statementList/default/eval-block.template
Normal file
29
src/statementList/default/eval-block.template
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
// Copyright (C) 2019 Leo Balter. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
path: language/statementList/eval-block-
|
||||||
|
name: Eval production of StatementList starting with a BlockStatement
|
||||||
|
esid: prod-StatementList
|
||||||
|
info: |
|
||||||
|
StatementList:
|
||||||
|
StatementListItem
|
||||||
|
StatementList StatementListItem
|
||||||
|
|
||||||
|
StatementListItem:
|
||||||
|
Statement
|
||||||
|
Declaration
|
||||||
|
|
||||||
|
Statement:
|
||||||
|
BlockStatement
|
||||||
|
|
||||||
|
BlockStatement:
|
||||||
|
Block
|
||||||
|
|
||||||
|
Block:
|
||||||
|
{ StatementList_opt }
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var result = eval('{}/*{ StatementListItem }*/');
|
||||||
|
|
||||||
|
/*{ EvalAssertions }*/
|
24
src/statementList/default/eval-class-declaration.template
Normal file
24
src/statementList/default/eval-class-declaration.template
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
// Copyright (C) 2019 Leo Balter. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
path: language/statementList/eval-class-
|
||||||
|
name: Valid syntax of StatementList starting with a Class Declaration
|
||||||
|
esid: prod-StatementList
|
||||||
|
info: |
|
||||||
|
StatementList:
|
||||||
|
StatementListItem
|
||||||
|
StatementList StatementListItem
|
||||||
|
|
||||||
|
StatementListItem:
|
||||||
|
Statement
|
||||||
|
Declaration
|
||||||
|
|
||||||
|
Declaration:
|
||||||
|
ClassDeclaration
|
||||||
|
features: [class]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var result = eval('class C {}/*{ StatementListItem }*/;');
|
||||||
|
|
||||||
|
/*{ EvalAssertions }*/
|
26
src/statementList/default/eval-function-declaration.template
Normal file
26
src/statementList/default/eval-function-declaration.template
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
// Copyright (C) 2019 Leo Balter. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
path: language/statementList/eval-fn-
|
||||||
|
name: Eval production of StatementList starting with a Function Declaration
|
||||||
|
esid: prod-StatementList
|
||||||
|
info: |
|
||||||
|
StatementList:
|
||||||
|
StatementListItem
|
||||||
|
StatementList StatementListItem
|
||||||
|
|
||||||
|
StatementListItem:
|
||||||
|
Statement
|
||||||
|
Declaration
|
||||||
|
|
||||||
|
Declaration:
|
||||||
|
HoistableDeclaration
|
||||||
|
|
||||||
|
FunctionDeclaration:
|
||||||
|
function BindingIdentifier ( FormalParameters ) { FunctionBody }
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var result = eval('function fn() {}/*{ StatementListItem }*/;');
|
||||||
|
|
||||||
|
/*{ EvalAssertions }*/
|
24
src/statementList/default/function-declaration.template
Normal file
24
src/statementList/default/function-declaration.template
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
// Copyright (C) 2019 Leo Balter. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
path: language/statementList/fn-
|
||||||
|
name: Valid syntax of StatementList starting with a Function Declaration
|
||||||
|
esid: prod-StatementList
|
||||||
|
info: |
|
||||||
|
StatementList:
|
||||||
|
StatementListItem
|
||||||
|
StatementList StatementListItem
|
||||||
|
|
||||||
|
StatementListItem:
|
||||||
|
Statement
|
||||||
|
Declaration
|
||||||
|
|
||||||
|
Declaration:
|
||||||
|
HoistableDeclaration
|
||||||
|
|
||||||
|
FunctionDeclaration:
|
||||||
|
function BindingIdentifier ( FormalParameters ) { FunctionBody }
|
||||||
|
---*/
|
||||||
|
|
||||||
|
function fn() {}/*{ StatementListItem }*/;
|
40
src/statementList/expr-arrow-function-boolean-literal.case
Normal file
40
src/statementList/expr-arrow-function-boolean-literal.case
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
// Copyright (C) 2019 Leo Balter. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
desc: Expression with an Arrow Function and Boolean literal
|
||||||
|
template: default
|
||||||
|
info: |
|
||||||
|
Statement:
|
||||||
|
BlockStatement
|
||||||
|
VariableStatement
|
||||||
|
EmptyStatement
|
||||||
|
ExpressionStatement
|
||||||
|
...
|
||||||
|
|
||||||
|
ExpressionStatement:
|
||||||
|
[lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }]
|
||||||
|
Expression ;
|
||||||
|
|
||||||
|
Expression:
|
||||||
|
AssignmentExpression
|
||||||
|
Expression , AssignmentExpression
|
||||||
|
|
||||||
|
AssignmentExpression:
|
||||||
|
ConditionalExpression
|
||||||
|
[+Yield]YieldExpression
|
||||||
|
ArrowFunction
|
||||||
|
|
||||||
|
ArrowFunction:
|
||||||
|
ArrowParameters [no LineTerminator here] => ConciseBody
|
||||||
|
|
||||||
|
ConciseBody:
|
||||||
|
[lookahead ≠ {] AssignmentExpression
|
||||||
|
{ FunctionBody }
|
||||||
|
features: [arrow-function]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
//- StatementListItem
|
||||||
|
() => 1, 42;
|
||||||
|
//- EvalAssertions
|
||||||
|
assert.sameValue(result, 42);
|
22
src/statementList/let-declaration.case
Normal file
22
src/statementList/let-declaration.case
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// Copyright (C) 2019 Leo Balter. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
desc: LexicalDeclaration using Let
|
||||||
|
template: default
|
||||||
|
info: |
|
||||||
|
Declaration:
|
||||||
|
LexicalDeclaration
|
||||||
|
|
||||||
|
LexicalDeclaration:
|
||||||
|
LetOrConst BindingList ;
|
||||||
|
|
||||||
|
BindingList:
|
||||||
|
LexicalBinding
|
||||||
|
BindingList , LexicalBinding
|
||||||
|
---*/
|
||||||
|
|
||||||
|
//- StatementListItem
|
||||||
|
let a, b = 42, c;b;
|
||||||
|
//- EvalAssertions
|
||||||
|
assert.sameValue(result, 42);
|
28
src/statementList/regexp-literal-flags.case
Normal file
28
src/statementList/regexp-literal-flags.case
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// Copyright (C) 2019 Leo Balter. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
desc: Regular Expression Literal with Flags
|
||||||
|
template: default
|
||||||
|
info: |
|
||||||
|
Statement:
|
||||||
|
BlockStatement
|
||||||
|
VariableStatement
|
||||||
|
EmptyStatement
|
||||||
|
ExpressionStatement
|
||||||
|
...
|
||||||
|
|
||||||
|
ExpressionStatement[Yield, Await]:
|
||||||
|
[lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }]
|
||||||
|
Expression ;
|
||||||
|
|
||||||
|
RegularExpressionLiteral ::
|
||||||
|
/ RegularExpressionBody / RegularExpressionFlags
|
||||||
|
---*/
|
||||||
|
|
||||||
|
//- StatementListItem
|
||||||
|
/1/g;
|
||||||
|
//- EvalAssertions
|
||||||
|
assert.sameValue(Object.getPrototypeOf(result), RegExp.prototype);
|
||||||
|
assert.sameValue(result.flags, 'g');
|
||||||
|
assert.sameValue(result.toString(), '/1/g');
|
28
src/statementList/regexp-literal.case
Normal file
28
src/statementList/regexp-literal.case
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// Copyright (C) 2019 Leo Balter. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
desc: Regular Expression Literal
|
||||||
|
template: default
|
||||||
|
info: |
|
||||||
|
Statement:
|
||||||
|
BlockStatement
|
||||||
|
VariableStatement
|
||||||
|
EmptyStatement
|
||||||
|
ExpressionStatement
|
||||||
|
...
|
||||||
|
|
||||||
|
ExpressionStatement[Yield, Await]:
|
||||||
|
[lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }]
|
||||||
|
Expression ;
|
||||||
|
|
||||||
|
RegularExpressionLiteral ::
|
||||||
|
/ RegularExpressionBody / RegularExpressionFlags
|
||||||
|
---*/
|
||||||
|
|
||||||
|
//- StatementListItem
|
||||||
|
/1/;
|
||||||
|
//- EvalAssertions
|
||||||
|
assert.sameValue(Object.getPrototypeOf(result), RegExp.prototype);
|
||||||
|
assert.sameValue(result.flags, '');
|
||||||
|
assert.sameValue(result.toString(), '/1/');
|
Loading…
x
Reference in New Issue
Block a user