mirror of https://github.com/tc39/test262.git
Add templates and cases for matchings of a StatementList
This commit is contained in:
parent
1dc78879d4
commit
c509173032
|
@ -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);
|
|
@ -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);
|
|
@ -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);
|
|
@ -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);
|
|
@ -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');
|
|
@ -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);
|
|
@ -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 }*/;
|
|
@ -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 }*/;
|
|
@ -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 }*/;
|
|
@ -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 }*/
|
|
@ -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 }*/
|
|
@ -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 }*/
|
|
@ -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 }*/
|
|
@ -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 }*/;
|
|
@ -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);
|
|
@ -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);
|
|
@ -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');
|
|
@ -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…
Reference in New Issue