mirror of
https://github.com/tc39/test262.git
synced 2025-07-31 01:44:54 +02:00
Add tests for evaluation and export declarations in TLA
This commit is contained in:
parent
69bf8fb0f8
commit
2e82d31eac
@ -24,4 +24,3 @@ template: syntax
|
|||||||
|
|
||||||
//- expr
|
//- expr
|
||||||
await ``
|
await ``
|
||||||
|
|
||||||
|
51
src/top-level-await/syntax/export-class-decl.template
Normal file
51
src/top-level-await/syntax/export-class-decl.template
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
// Copyright (C) 2019 Leo Balter. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
path: language/module-code/top-level-await/syntax/export-class-decl-
|
||||||
|
name: Valid syntax for top level await in export ClassDeclaration
|
||||||
|
esid: prod-AwaitExpression
|
||||||
|
info: |
|
||||||
|
ModuleItem:
|
||||||
|
StatementListItem[~Yield, +Await, ~Return]
|
||||||
|
|
||||||
|
...
|
||||||
|
|
||||||
|
UnaryExpression[Yield, Await]
|
||||||
|
[+Await]AwaitExpression[?Yield]
|
||||||
|
|
||||||
|
AwaitExpression[Yield]:
|
||||||
|
await UnaryExpression[?Yield, +Await]
|
||||||
|
|
||||||
|
...
|
||||||
|
|
||||||
|
ExportDeclaration:
|
||||||
|
export * FromClause ;
|
||||||
|
export ExportClause FromClause ;
|
||||||
|
export ExportClause ;
|
||||||
|
export VariableStatement[~Yield, +Await]
|
||||||
|
export Declaration[~Yield, +Await]
|
||||||
|
export defaultHoistableDeclaration[~Yield, +Await, +Default]
|
||||||
|
export defaultClassDeclaration[~Yield, +Await, +Default]
|
||||||
|
export default[lookahead ∉ { function, async [no LineTerminator here] function, class }]AssignmentExpression[+In, ~Yield, ~Await];
|
||||||
|
|
||||||
|
Declaration[Yield, Await]:
|
||||||
|
HoistableDeclaration[?Yield, ?Await, ~Default]
|
||||||
|
ClassDeclaration[?Yield, ?Await, ~Default]
|
||||||
|
LexicalDeclaration[+In, ?Yield, ?Await]
|
||||||
|
|
||||||
|
ClassDeclaration[Yield, Await, Default]:
|
||||||
|
classBindingIdentifier[?Yield, ?Await] ClassTail[?Yield, ?Await]
|
||||||
|
[+Default] class ClassTail[?Yield, ?Await]
|
||||||
|
|
||||||
|
ClassTail[Yield, Await]:
|
||||||
|
ClassHeritage[?Yield, ?Await]_opt { ClassBody[?Yield, ?Await]_opt }
|
||||||
|
flags: [module]
|
||||||
|
features: [top-level-await, class]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
function fn() {
|
||||||
|
return function() {};
|
||||||
|
}
|
||||||
|
// extends CallExpression with arguments
|
||||||
|
export class C extends fn(/*{ expr }*/) {};
|
47
src/top-level-await/syntax/export-dflt-assign-expr.template
Normal file
47
src/top-level-await/syntax/export-dflt-assign-expr.template
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
// Copyright (C) 2019 Leo Balter. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
path: language/module-code/top-level-await/syntax/export-dflt-assign-expr-
|
||||||
|
name: Valid syntax for top level await in export default AssignmentExpression
|
||||||
|
esid: prod-AwaitExpression
|
||||||
|
info: |
|
||||||
|
ModuleItem:
|
||||||
|
StatementListItem[~Yield, +Await, ~Return]
|
||||||
|
|
||||||
|
...
|
||||||
|
|
||||||
|
UnaryExpression[Yield, Await]
|
||||||
|
[+Await]AwaitExpression[?Yield]
|
||||||
|
|
||||||
|
AwaitExpression[Yield]:
|
||||||
|
await UnaryExpression[?Yield, +Await]
|
||||||
|
|
||||||
|
...
|
||||||
|
|
||||||
|
ExportDeclaration:
|
||||||
|
export * FromClause ;
|
||||||
|
export ExportClause FromClause ;
|
||||||
|
export ExportClause ;
|
||||||
|
export VariableStatement[~Yield, +Await]
|
||||||
|
export Declaration[~Yield, +Await]
|
||||||
|
export defaultHoistableDeclaration[~Yield, +Await, +Default]
|
||||||
|
export defaultClassDeclaration[~Yield, +Await, +Default]
|
||||||
|
export default [lookahead ∉ { function, async [no LineTerminator here] function, class }] AssignmentExpression [+In, ~Yield, ~Await];
|
||||||
|
|
||||||
|
Declaration[Yield, Await]:
|
||||||
|
HoistableDeclaration[?Yield, ?Await, ~Default]
|
||||||
|
ClassDeclaration[?Yield, ?Await, ~Default]
|
||||||
|
LexicalDeclaration[+In, ?Yield, ?Await]
|
||||||
|
|
||||||
|
ClassDeclaration[Yield, Await, Default]:
|
||||||
|
classBindingIdentifier[?Yield, ?Await] ClassTail[?Yield, ?Await]
|
||||||
|
[+Default] class ClassTail[?Yield, ?Await]
|
||||||
|
|
||||||
|
ClassTail[Yield, Await]:
|
||||||
|
ClassHeritage[?Yield, ?Await]_opt { ClassBody[?Yield, ?Await]_opt }
|
||||||
|
flags: [module]
|
||||||
|
features: [top-level-await, class]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
export default /*{ expr }*/;
|
51
src/top-level-await/syntax/export-dflt-class-decl.template
Normal file
51
src/top-level-await/syntax/export-dflt-class-decl.template
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
// Copyright (C) 2019 Leo Balter. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
path: language/module-code/top-level-await/syntax/export-dft-class-decl-
|
||||||
|
name: Valid syntax for top level await in export default ClassDeclaration
|
||||||
|
esid: prod-AwaitExpression
|
||||||
|
info: |
|
||||||
|
ModuleItem:
|
||||||
|
StatementListItem[~Yield, +Await, ~Return]
|
||||||
|
|
||||||
|
...
|
||||||
|
|
||||||
|
UnaryExpression[Yield, Await]
|
||||||
|
[+Await]AwaitExpression[?Yield]
|
||||||
|
|
||||||
|
AwaitExpression[Yield]:
|
||||||
|
await UnaryExpression[?Yield, +Await]
|
||||||
|
|
||||||
|
...
|
||||||
|
|
||||||
|
ExportDeclaration:
|
||||||
|
export * FromClause ;
|
||||||
|
export ExportClause FromClause ;
|
||||||
|
export ExportClause ;
|
||||||
|
export VariableStatement[~Yield, +Await]
|
||||||
|
export Declaration[~Yield, +Await]
|
||||||
|
export defaultHoistableDeclaration[~Yield, +Await, +Default]
|
||||||
|
export defaultClassDeclaration[~Yield, +Await, +Default]
|
||||||
|
export default[lookahead ∉ { function, async [no LineTerminator here] function, class }]AssignmentExpression[+In, ~Yield, ~Await];
|
||||||
|
|
||||||
|
Declaration[Yield, Await]:
|
||||||
|
HoistableDeclaration[?Yield, ?Await, ~Default]
|
||||||
|
ClassDeclaration[?Yield, ?Await, ~Default]
|
||||||
|
LexicalDeclaration[+In, ?Yield, ?Await]
|
||||||
|
|
||||||
|
ClassDeclaration[Yield, Await, Default]:
|
||||||
|
classBindingIdentifier[?Yield, ?Await] ClassTail[?Yield, ?Await]
|
||||||
|
[+Default] class ClassTail[?Yield, ?Await]
|
||||||
|
|
||||||
|
ClassTail[Yield, Await]:
|
||||||
|
ClassHeritage[?Yield, ?Await]_opt { ClassBody[?Yield, ?Await]_opt }
|
||||||
|
flags: [module]
|
||||||
|
features: [top-level-await, class]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
function fn() {
|
||||||
|
return function() {};
|
||||||
|
}
|
||||||
|
// extends CallExpression with arguments
|
||||||
|
export default class extends fn(/*{ expr }*/) {};
|
44
src/top-level-await/syntax/export-lex-declaration.template
Normal file
44
src/top-level-await/syntax/export-lex-declaration.template
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
// Copyright (C) 2019 Leo Balter. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
path: language/module-code/top-level-await/syntax/export-lex-decl-
|
||||||
|
name: Valid syntax for top level await in export LexicalDeclaration
|
||||||
|
esid: prod-AwaitExpression
|
||||||
|
info: |
|
||||||
|
ModuleItem:
|
||||||
|
StatementListItem[~Yield, +Await, ~Return]
|
||||||
|
|
||||||
|
...
|
||||||
|
|
||||||
|
UnaryExpression[Yield, Await]
|
||||||
|
[+Await]AwaitExpression[?Yield]
|
||||||
|
|
||||||
|
AwaitExpression[Yield]:
|
||||||
|
await UnaryExpression[?Yield, +Await]
|
||||||
|
|
||||||
|
...
|
||||||
|
|
||||||
|
ExportDeclaration:
|
||||||
|
export * FromClause ;
|
||||||
|
export ExportClause FromClause ;
|
||||||
|
export ExportClause ;
|
||||||
|
export VariableStatement[~Yield, +Await]
|
||||||
|
export Declaration[~Yield, +Await]
|
||||||
|
export defaultHoistableDeclaration[~Yield, +Await, +Default]
|
||||||
|
export defaultClassDeclaration[~Yield, +Await, +Default]
|
||||||
|
export default[lookahead ∉ { function, async [no LineTerminator here] function, class }]AssignmentExpression[+In, ~Yield, ~Await];
|
||||||
|
|
||||||
|
Declaration[Yield, Await]:
|
||||||
|
HoistableDeclaration[?Yield, ?Await, ~Default]
|
||||||
|
ClassDeclaration[?Yield, ?Await, ~Default]
|
||||||
|
LexicalDeclaration[+In, ?Yield, ?Await]
|
||||||
|
|
||||||
|
LexicalDeclaration[In, Yield, Await]:
|
||||||
|
LetOrConstBindingList[?In, ?Yield, ?Await];
|
||||||
|
flags: [module]
|
||||||
|
features: [top-level-await]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
export let x = /*{ expr }*/;
|
||||||
|
export const y = /*{ expr }*/;
|
47
src/top-level-await/syntax/export-var-init.template
Normal file
47
src/top-level-await/syntax/export-var-init.template
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
// Copyright (C) 2019 Leo Balter. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
path: language/module-code/top-level-await/syntax/export-var-
|
||||||
|
name: Valid syntax for top level await in export var BindingIdentifier Await_initializer
|
||||||
|
esid: prod-AwaitExpression
|
||||||
|
info: |
|
||||||
|
ModuleItem:
|
||||||
|
StatementListItem[~Yield, +Await, ~Return]
|
||||||
|
|
||||||
|
...
|
||||||
|
|
||||||
|
UnaryExpression[Yield, Await]
|
||||||
|
[+Await]AwaitExpression[?Yield]
|
||||||
|
|
||||||
|
AwaitExpression[Yield]:
|
||||||
|
await UnaryExpression[?Yield, +Await]
|
||||||
|
|
||||||
|
...
|
||||||
|
|
||||||
|
ExportDeclaration:
|
||||||
|
export * FromClause ;
|
||||||
|
export ExportClause FromClause ;
|
||||||
|
export ExportClause ;
|
||||||
|
export VariableStatement[~Yield, +Await]
|
||||||
|
export Declaration[~Yield, +Await]
|
||||||
|
export defaultHoistableDeclaration[~Yield, +Await, +Default]
|
||||||
|
export defaultClassDeclaration[~Yield, +Await, +Default]
|
||||||
|
export default[lookahead ∉ { function, async [no LineTerminator here] function, class }]AssignmentExpression[+In, ~Yield, ~Await];
|
||||||
|
|
||||||
|
VariableStatement[Yield, Await]:
|
||||||
|
var VariableDeclarationList[+In, ?Yield, ?Await];
|
||||||
|
|
||||||
|
VariableDeclarationList[In, Yield, Await]:
|
||||||
|
VariableDeclaration[?In, ?Yield, ?Await]
|
||||||
|
VariableDeclarationList[?In, ?Yield, ?Await] , VariableDeclaration[?In, ?Yield, ?Await]
|
||||||
|
|
||||||
|
VariableDeclaration[In, Yield, Await]:
|
||||||
|
BindingIdentifier[?Yield, ?Await] Initializer[?In, ?Yield, ?Await]opt
|
||||||
|
BindingPattern[?Yield, ?Await] Initializer[?In, ?Yield, ?Await]
|
||||||
|
flags: [module]
|
||||||
|
features: [top-level-await]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
export var name1 = /*{ expr }*/;
|
||||||
|
export var { x = /*{ expr }*/ } = {};
|
55
src/top-level-await/syntax/for-expr.template
Normal file
55
src/top-level-await/syntax/for-expr.template
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
// Copyright (C) 2019 Leo Balter. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
path: language/module-code/top-level-await/syntax/for-
|
||||||
|
name: Valid syntax for top level await in for statements.
|
||||||
|
esid: prod-AwaitExpression
|
||||||
|
info: |
|
||||||
|
ModuleItem:
|
||||||
|
StatementListItem[~Yield, +Await, ~Return]
|
||||||
|
|
||||||
|
...
|
||||||
|
|
||||||
|
IterationStatement[Yield, Await, Return]:
|
||||||
|
...
|
||||||
|
for ( [ lookahead ≠ let [] Expression[~In, ?Yield, ?Await]opt ; Expression[+In, ?Yield, ?Await]opt ; Expression[+In, ?Yield, ?Await]opt ) Statement[?Yield, ?Await, ?Return]
|
||||||
|
for ( var VariableDeclarationList[~In, ?Yield, ?Await] ; Expression[+In, ?Yield, ?Await]opt ; Expression[+In, ?Yield, ?Await]opt ) Statement[?Yield, ?Await, ?Return]
|
||||||
|
for ( LexicalDeclaration[~In, ?Yield, ?Await] Expression[+In, ?Yield, ?Await]opt ; Expression[+In, ?Yield, ?Await]opt ) Statement[?Yield, ?Await, ?Return]
|
||||||
|
for ( [lookahead ≠ let [] LeftHandSideExpression[?Yield, ?Await] in Expression[+In, ?Yield, ?Await] ) Statement[?Yield, ?Await, ?Return]
|
||||||
|
for ( var ForBinding[?Yield, ?Await] in Expression[+In, ?Yield, ?Await] ) Statement[?Yield, ?Await, ?Return]
|
||||||
|
for ( ForDeclaration[?Yield, ?Await] in Expression[+In, ?Yield, ?Await] ) Statement[?Yield, ?Await, ?Return]
|
||||||
|
for ( [lookahead ≠ let] LeftHandSideExpression[?Yield, ?Await] of AssignmentExpression[+In, ?Yield, ?Await] ) Statement[?Yield, ?Await, ?Return]
|
||||||
|
for ( var ForBinding[?Yield, ?Await] of AssignmentExpression[+In, ?Yield, ?Await] ) Statement[?Yield, ?Await, ?Return]
|
||||||
|
for ( ForDeclaration[?Yield, ?Await] of AssignmentExpression[+In, ?Yield, ?Await] ) Statement[?Yield, ?Await, ?Return]
|
||||||
|
...
|
||||||
|
|
||||||
|
...
|
||||||
|
|
||||||
|
UnaryExpression[Yield, Await]
|
||||||
|
[+Await]AwaitExpression[?Yield]
|
||||||
|
|
||||||
|
AwaitExpression[Yield]:
|
||||||
|
await UnaryExpression[?Yield, +Await]
|
||||||
|
|
||||||
|
...
|
||||||
|
features: [top-level-await]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
// for ( [ lookahead ≠ let [] Expression[~In, ?Yield, ?Await]opt ; Expression[+In, ?Yield, ?Await]opt ; Expression[+In, ?Yield, ?Await]opt ) Statement[?Yield, ?Await, ?Return]
|
||||||
|
for ( /*{ expr }*/ ; /*{ expr }*/; /*{ expr }*/ ) {
|
||||||
|
/*{ expr }*/;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// for ( var VariableDeclarationList[~In, ?Yield, ?Await] ; Expression[+In, ?Yield, ?Await]opt ; Expression[+In, ?Yield, ?Await]opt ) Statement[?Yield, ?Await, ?Return]
|
||||||
|
for ( var binding; /*{ expr }*/; /*{ expr }*/ ) {
|
||||||
|
/*{ expr }*/;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// for ( LexicalDeclaration[~In, ?Yield, ?Await] Expression[+In, ?Yield, ?Await]opt ; Expression[+In, ?Yield, ?Await]opt ) Statement[?Yield, ?Await, ?Return]
|
||||||
|
for ( let binding; /*{ expr }*/; /*{ expr }*/ ) {
|
||||||
|
/*{ expr }*/;
|
||||||
|
break;
|
||||||
|
}
|
57
src/top-level-await/syntax/for-in-expr.template
Normal file
57
src/top-level-await/syntax/for-in-expr.template
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
// Copyright (C) 2019 Leo Balter. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
path: language/module-code/top-level-await/syntax/for-in-
|
||||||
|
name: Valid syntax for top level await in for-in statements.
|
||||||
|
esid: prod-AwaitExpression
|
||||||
|
info: |
|
||||||
|
ModuleItem:
|
||||||
|
StatementListItem[~Yield, +Await, ~Return]
|
||||||
|
|
||||||
|
...
|
||||||
|
|
||||||
|
IterationStatement[Yield, Await, Return]:
|
||||||
|
...
|
||||||
|
for ( [ lookahead ≠ let []Expression[~In, ?Yield, ?Await]opt ; Expression[+In, ?Yield, ?Await]opt ; Expression[+In, ?Yield, ?Await]opt ) Statement[?Yield, ?Await, ?Return]
|
||||||
|
for ( var VariableDeclarationList[~In, ?Yield, ?Await] ; Expression[+In, ?Yield, ?Await]opt ; Expression[+In, ?Yield, ?Await]opt ) Statement[?Yield, ?Await, ?Return]
|
||||||
|
for ( LexicalDeclaration[~In, ?Yield, ?Await] Expression[+In, ?Yield, ?Await]opt ; Expression[+In, ?Yield, ?Await]opt ) Statement[?Yield, ?Await, ?Return]
|
||||||
|
for ( [lookahead ≠ let [] LeftHandSideExpression[?Yield, ?Await] in Expression[+In, ?Yield, ?Await] ) Statement[?Yield, ?Await, ?Return]
|
||||||
|
for ( var ForBinding[?Yield, ?Await] in Expression[+In, ?Yield, ?Await] ) Statement[?Yield, ?Await, ?Return]
|
||||||
|
for ( ForDeclaration[?Yield, ?Await] in Expression[+In, ?Yield, ?Await] ) Statement[?Yield, ?Await, ?Return]
|
||||||
|
for ( [lookahead ≠ let] LeftHandSideExpression[?Yield, ?Await] of AssignmentExpression[+In, ?Yield, ?Await] ) Statement[?Yield, ?Await, ?Return]
|
||||||
|
for ( var ForBinding[?Yield, ?Await] of AssignmentExpression[+In, ?Yield, ?Await] ) Statement[?Yield, ?Await, ?Return]
|
||||||
|
for ( ForDeclaration[?Yield, ?Await] of AssignmentExpression[+In, ?Yield, ?Await] ) Statement[?Yield, ?Await, ?Return]
|
||||||
|
...
|
||||||
|
|
||||||
|
...
|
||||||
|
|
||||||
|
UnaryExpression[Yield, Await]
|
||||||
|
[+Await]AwaitExpression[?Yield]
|
||||||
|
|
||||||
|
AwaitExpression[Yield]:
|
||||||
|
await UnaryExpression[?Yield, +Await]
|
||||||
|
|
||||||
|
...
|
||||||
|
features: [top-level-await]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var binding;
|
||||||
|
|
||||||
|
// for ( [lookahead ≠ let [] LeftHandSideExpression[?Yield, ?Await] in Expression[+In, ?Yield, ?Await] ) Statement[?Yield, ?Await, ?Return]
|
||||||
|
for (binding in [/*{ expr }*/]) {
|
||||||
|
/*{ expr }*/;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// for ( var ForBinding[?Yield, ?Await] in Expression[+In, ?Yield, ?Await] ) Statement[?Yield, ?Await, ?Return]
|
||||||
|
for (var binding in [/*{ expr }*/]) {
|
||||||
|
/*{ expr }*/;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// for ( ForDeclaration[?Yield, ?Await] in Expression[+In, ?Yield, ?Await] ) Statement[?Yield, ?Await, ?Return]
|
||||||
|
for (let binding in [/*{ expr }*/]) {
|
||||||
|
/*{ expr }*/;
|
||||||
|
break;
|
||||||
|
}
|
57
src/top-level-await/syntax/for-of-expr.template
Normal file
57
src/top-level-await/syntax/for-of-expr.template
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
// Copyright (C) 2019 Leo Balter. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
path: language/module-code/top-level-await/syntax/for-of-
|
||||||
|
name: Valid syntax for top level await in for-of statements.
|
||||||
|
esid: prod-AwaitExpression
|
||||||
|
info: |
|
||||||
|
ModuleItem:
|
||||||
|
StatementListItem[~Yield, +Await, ~Return]
|
||||||
|
|
||||||
|
...
|
||||||
|
|
||||||
|
IterationStatement[Yield, Await, Return]:
|
||||||
|
...
|
||||||
|
for ( [ lookahead ≠ let []Expression[~In, ?Yield, ?Await]opt ; Expression[+In, ?Yield, ?Await]opt ; Expression[+In, ?Yield, ?Await]opt ) Statement[?Yield, ?Await, ?Return]
|
||||||
|
for ( var VariableDeclarationList[~In, ?Yield, ?Await] ; Expression[+In, ?Yield, ?Await]opt ; Expression[+In, ?Yield, ?Await]opt ) Statement[?Yield, ?Await, ?Return]
|
||||||
|
for ( LexicalDeclaration[~In, ?Yield, ?Await] Expression[+In, ?Yield, ?Await]opt ; Expression[+In, ?Yield, ?Await]opt ) Statement[?Yield, ?Await, ?Return]
|
||||||
|
for ( [lookahead ≠ let [] LeftHandSideExpression[?Yield, ?Await] in Expression[+In, ?Yield, ?Await] ) Statement[?Yield, ?Await, ?Return]
|
||||||
|
for ( var ForBinding[?Yield, ?Await] in Expression[+In, ?Yield, ?Await] ) Statement[?Yield, ?Await, ?Return]
|
||||||
|
for ( ForDeclaration[?Yield, ?Await] in Expression[+In, ?Yield, ?Await] ) Statement[?Yield, ?Await, ?Return]
|
||||||
|
for ( [lookahead ≠ let] LeftHandSideExpression[?Yield, ?Await] of AssignmentExpression[+In, ?Yield, ?Await] ) Statement[?Yield, ?Await, ?Return]
|
||||||
|
for ( var ForBinding[?Yield, ?Await] of AssignmentExpression[+In, ?Yield, ?Await] ) Statement[?Yield, ?Await, ?Return]
|
||||||
|
for ( ForDeclaration[?Yield, ?Await] of AssignmentExpression[+In, ?Yield, ?Await] ) Statement[?Yield, ?Await, ?Return]
|
||||||
|
...
|
||||||
|
|
||||||
|
...
|
||||||
|
|
||||||
|
UnaryExpression[Yield, Await]
|
||||||
|
[+Await]AwaitExpression[?Yield]
|
||||||
|
|
||||||
|
AwaitExpression[Yield]:
|
||||||
|
await UnaryExpression[?Yield, +Await]
|
||||||
|
|
||||||
|
...
|
||||||
|
features: [top-level-await]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var binding;
|
||||||
|
|
||||||
|
// for ( [lookahead ≠ let] LeftHandSideExpression[?Yield, ?Await] of AssignmentExpression[+In, ?Yield, ?Await] ) Statement[?Yield, ?Await, ?Return]
|
||||||
|
for (binding of [/*{ expr }*/]) {
|
||||||
|
/*{ expr }*/;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// for ( var ForBinding[?Yield, ?Await] of AssignmentExpression[+In, ?Yield, ?Await] ) Statement[?Yield, ?Await, ?Return]
|
||||||
|
for (var binding of [/*{ expr }*/]) {
|
||||||
|
/*{ expr }*/;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// for ( ForDeclaration[?Yield, ?Await] of AssignmentExpression[+In, ?Yield, ?Await] ) Statement[?Yield, ?Await, ?Return]
|
||||||
|
for (let binding of [/*{ expr }*/]) {
|
||||||
|
/*{ expr }*/;
|
||||||
|
break;
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
// Copyright 2019 Leo Balter. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: prod-AwaitExpression
|
||||||
|
description: >
|
||||||
|
Await can await any thenable. If the thenable's then is not callable,
|
||||||
|
await evaluates to the thenable
|
||||||
|
flags: [module, async]
|
||||||
|
features: [top-level-await]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var thenable = { then: 42 };
|
||||||
|
var res = await thenable;
|
||||||
|
assert.sameValue(res, thenable);
|
||||||
|
|
||||||
|
$DONE();
|
||||||
|
|
@ -0,0 +1,29 @@
|
|||||||
|
// Copyright 2019 Leo Balter. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: prod-AwaitExpression
|
||||||
|
description: >
|
||||||
|
Await can await any thenable.
|
||||||
|
flags: [module, async]
|
||||||
|
features: [top-level-await]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var error = {};
|
||||||
|
var thenable = {
|
||||||
|
then: function (resolve, reject) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var caught = false;
|
||||||
|
try {
|
||||||
|
await thenable;
|
||||||
|
} catch(e) {
|
||||||
|
caught = e;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.sameValue(caught, error);
|
||||||
|
|
||||||
|
$DONE();
|
@ -0,0 +1,20 @@
|
|||||||
|
// Copyright 2019 Leo Balter. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: prod-AwaitExpression
|
||||||
|
description: >
|
||||||
|
Await can await any thenable.
|
||||||
|
flags: [module, async]
|
||||||
|
features: [top-level-await]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var thenable = {
|
||||||
|
then: function (resolve, reject) {
|
||||||
|
resolve(42);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.sameValue(await thenable, 42);
|
||||||
|
|
||||||
|
$DONE();
|
@ -0,0 +1,91 @@
|
|||||||
|
// Copyright (C) 2019 Leo Balter. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
description: >
|
||||||
|
AwaitExpression evaluates to abrupt completions in promise rejections
|
||||||
|
info: |
|
||||||
|
ModuleItem:
|
||||||
|
StatementListItem[~Yield, +Await, ~Return]
|
||||||
|
|
||||||
|
...
|
||||||
|
|
||||||
|
UnaryExpression[Yield, Await]
|
||||||
|
void UnaryExpression[?Yield, ?Await]
|
||||||
|
[+Await]AwaitExpression[?Yield]
|
||||||
|
|
||||||
|
AwaitExpression[Yield]:
|
||||||
|
await UnaryExpression[?Yield, +Await]
|
||||||
|
esid: prod-AwaitExpression
|
||||||
|
flags: [module, async]
|
||||||
|
features: [top-level-await]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var x;
|
||||||
|
|
||||||
|
try {
|
||||||
|
await Promise.reject(42);
|
||||||
|
} catch (e) {
|
||||||
|
x = e;
|
||||||
|
}
|
||||||
|
assert.sameValue(x, 42, 'number');
|
||||||
|
|
||||||
|
try {
|
||||||
|
await Promise.reject('');
|
||||||
|
} catch (e) {
|
||||||
|
x = e;
|
||||||
|
}
|
||||||
|
assert.sameValue(x, '', 'string');
|
||||||
|
|
||||||
|
try {
|
||||||
|
var s = Symbol();
|
||||||
|
await Promise.reject(s);
|
||||||
|
} catch (e) {
|
||||||
|
x = e;
|
||||||
|
}
|
||||||
|
assert.sameValue(x, s, 'symbol');
|
||||||
|
|
||||||
|
try {
|
||||||
|
await Promise.reject(false);
|
||||||
|
} catch (e) {
|
||||||
|
x = e;
|
||||||
|
}
|
||||||
|
assert.sameValue(x, false, 'false');
|
||||||
|
|
||||||
|
try {
|
||||||
|
await Promise.reject(true);
|
||||||
|
} catch (e) {
|
||||||
|
x = e;
|
||||||
|
}
|
||||||
|
assert.sameValue(x, true, 'true');
|
||||||
|
|
||||||
|
try {
|
||||||
|
await Promise.reject(NaN);
|
||||||
|
} catch (e) {
|
||||||
|
x = e;
|
||||||
|
}
|
||||||
|
assert.sameValue(x, NaN, 'NaN');
|
||||||
|
|
||||||
|
try {
|
||||||
|
await Promise.reject(null);
|
||||||
|
} catch (e) {
|
||||||
|
x = e;
|
||||||
|
}
|
||||||
|
assert.sameValue(x, null, 'null');
|
||||||
|
|
||||||
|
try {
|
||||||
|
await Promise.reject(undefined);
|
||||||
|
} catch (e) {
|
||||||
|
x = e;
|
||||||
|
}
|
||||||
|
assert.sameValue(x, undefined, 'undefined');
|
||||||
|
|
||||||
|
try {
|
||||||
|
var obj = {};
|
||||||
|
await Promise.reject(obj);
|
||||||
|
} catch (e) {
|
||||||
|
x = e;
|
||||||
|
}
|
||||||
|
assert.sameValue(x, obj, 'object');
|
||||||
|
|
||||||
|
$DONE();
|
@ -0,0 +1,58 @@
|
|||||||
|
// Copyright (C) 2019 Leo Balter. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
description: >
|
||||||
|
AwaitExpression Resolutions
|
||||||
|
info: |
|
||||||
|
ModuleItem:
|
||||||
|
StatementListItem[~Yield, +Await, ~Return]
|
||||||
|
|
||||||
|
...
|
||||||
|
|
||||||
|
UnaryExpression[Yield, Await]
|
||||||
|
void UnaryExpression[?Yield, ?Await]
|
||||||
|
[+Await]AwaitExpression[?Yield]
|
||||||
|
|
||||||
|
AwaitExpression[Yield]:
|
||||||
|
await UnaryExpression[?Yield, +Await]
|
||||||
|
esid: prod-AwaitExpression
|
||||||
|
flags: [module, async]
|
||||||
|
features: [top-level-await]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var x;
|
||||||
|
|
||||||
|
x = await 42;
|
||||||
|
assert.sameValue(x, 42, 'number');
|
||||||
|
|
||||||
|
x = await '';
|
||||||
|
assert.sameValue(x, '', 'string');
|
||||||
|
|
||||||
|
var s = Symbol();
|
||||||
|
x = await s;
|
||||||
|
assert.sameValue(x, s, 'symbol');
|
||||||
|
|
||||||
|
x = await false;
|
||||||
|
assert.sameValue(x, false, 'false');
|
||||||
|
|
||||||
|
x = await true;
|
||||||
|
assert.sameValue(x, true, 'true');
|
||||||
|
|
||||||
|
x = await NaN;
|
||||||
|
assert.sameValue(x, NaN, 'NaN');
|
||||||
|
|
||||||
|
x = await null;
|
||||||
|
assert.sameValue(x, null, 'null');
|
||||||
|
|
||||||
|
x = await undefined;
|
||||||
|
assert.sameValue(x, undefined, 'undefined');
|
||||||
|
|
||||||
|
var obj = {};
|
||||||
|
x = await obj;
|
||||||
|
assert.sameValue(x, obj, 'object');
|
||||||
|
|
||||||
|
x = await Promise.resolve(1).then(v => v * 2).then(v => v * 3);
|
||||||
|
assert.sameValue(x, 6, 'promise');
|
||||||
|
|
||||||
|
$DONE();
|
28
test/language/module-code/top-level-await/await-void-expr.js
Normal file
28
test/language/module-code/top-level-await/await-void-expr.js
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.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
description: >
|
||||||
|
AwaitExpression void resolves into undefined
|
||||||
|
info: |
|
||||||
|
ModuleItem:
|
||||||
|
StatementListItem[~Yield, +Await, ~Return]
|
||||||
|
|
||||||
|
...
|
||||||
|
|
||||||
|
UnaryExpression[Yield, Await]
|
||||||
|
void UnaryExpression[?Yield, ?Await]
|
||||||
|
[+Await]AwaitExpression[?Yield]
|
||||||
|
|
||||||
|
AwaitExpression[Yield]:
|
||||||
|
await UnaryExpression[?Yield, +Await]
|
||||||
|
esid: prod-AwaitExpression
|
||||||
|
flags: [module, async]
|
||||||
|
features: [top-level-await]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var x = await void 1;
|
||||||
|
|
||||||
|
assert.sameValue(x, undefined);
|
||||||
|
|
||||||
|
$DONE();
|
@ -0,0 +1,17 @@
|
|||||||
|
// Copyright 2019 Leo Balter. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: prod-AwaitExpression
|
||||||
|
description: >
|
||||||
|
await is not a simple assignment target and cannot be assigned to.
|
||||||
|
negative:
|
||||||
|
phase: parse
|
||||||
|
type: SyntaxError
|
||||||
|
flags: [module]
|
||||||
|
features: [top-level-await]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
$DONOTEVALUATE();
|
||||||
|
|
||||||
|
(await 1) = 1;
|
32
test/language/module-code/top-level-await/if-await-expr.js
Normal file
32
test/language/module-code/top-level-await/if-await-expr.js
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
// Copyright (C) 2019 Leo Balter. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
description: >
|
||||||
|
Evaluate Await expression for IfStatement
|
||||||
|
info: |
|
||||||
|
ModuleItem:
|
||||||
|
StatementListItem[~Yield, +Await, ~Return]
|
||||||
|
|
||||||
|
...
|
||||||
|
|
||||||
|
UnaryExpression[Yield, Await]
|
||||||
|
[+Await]AwaitExpression[?Yield]
|
||||||
|
|
||||||
|
AwaitExpression[Yield]:
|
||||||
|
await UnaryExpression[?Yield, +Await]
|
||||||
|
esid: prod-AwaitExpression
|
||||||
|
flags: [module, async]
|
||||||
|
features: [top-level-await]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var completed = 0;
|
||||||
|
var p = Promise.resolve(true);
|
||||||
|
|
||||||
|
if (await p) {
|
||||||
|
completed += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.sameValue(completed, 1);
|
||||||
|
|
||||||
|
$DONE();
|
17
test/language/module-code/top-level-await/no-operand.js
Normal file
17
test/language/module-code/top-level-await/no-operand.js
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
// Copyright 2019 Leo Balter. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: prod-AwaitExpression
|
||||||
|
description: >
|
||||||
|
await requries an operand.
|
||||||
|
negative:
|
||||||
|
phase: parse
|
||||||
|
type: SyntaxError
|
||||||
|
flags: [module]
|
||||||
|
features: [top-level-await]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
$DONOTEVALUATE();
|
||||||
|
|
||||||
|
await;
|
@ -39,9 +39,6 @@ flags: [module]
|
|||||||
features: [top-level-await, dynamic-import]
|
features: [top-level-await, dynamic-import]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
try {} catch (await e) {}
|
try {} catch ({ x = await 42 }) {} // Initializer
|
||||||
try {} catch (await {}) {}
|
try {} catch ({ x: y = await 42 }) {} // BindingElement Initializer
|
||||||
try {} catch (await { x: await 42 }) {} // BindingElement
|
try {} catch ([ x = await 42 ]) {}
|
||||||
try {} catch (await { x = await 42 }) {} // Initializer
|
|
||||||
try {} catch (await []) {}
|
|
||||||
try {} catch (await [ x = await 42 ]) {}
|
|
||||||
|
@ -0,0 +1,46 @@
|
|||||||
|
// Copyright (C) 2019 Leo Balter. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-asyncblockstart
|
||||||
|
description: >
|
||||||
|
Evaluation of await ticks order
|
||||||
|
info: |
|
||||||
|
AsyncBlockStart ( promiseCapability, asyncBody, asyncContext )
|
||||||
|
|
||||||
|
1. Assert: promiseCapability is a PromiseCapability Record.
|
||||||
|
2. Let runningContext be the running execution context.
|
||||||
|
3. Set the code evaluation state of asyncContext such that when evaluation is resumed for that execution context the following steps will be performed:
|
||||||
|
a. Let result be the result of evaluating asyncBody.
|
||||||
|
...
|
||||||
|
includes: [compareArray.js]
|
||||||
|
flags: [module, async]
|
||||||
|
features: [top-level-await]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var expected = [
|
||||||
|
'await 1',
|
||||||
|
'tick 1',
|
||||||
|
'await 2',
|
||||||
|
'tick 2',
|
||||||
|
'await 3',
|
||||||
|
'tick 3',
|
||||||
|
'await 4',
|
||||||
|
'tick 4',
|
||||||
|
];
|
||||||
|
|
||||||
|
var actual = [];
|
||||||
|
|
||||||
|
Promise.resolve(0)
|
||||||
|
.then(() => actual.push('tick 1'))
|
||||||
|
.then(() => actual.push('tick 2'))
|
||||||
|
.then(() => actual.push('tick 3'))
|
||||||
|
.then(() => actual.push('tick 4'))
|
||||||
|
.then(() => {
|
||||||
|
assert.compareArray(actual, expected, 'Ticks for top level await and promises');
|
||||||
|
}).then($DONE, $DONE);
|
||||||
|
|
||||||
|
await actual.push('await 1');
|
||||||
|
await actual.push('await 2');
|
||||||
|
await actual.push('await 3');
|
||||||
|
await actual.push('await 4');
|
46
test/language/module-code/top-level-await/top-level-ticks.js
Normal file
46
test/language/module-code/top-level-await/top-level-ticks.js
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
// Copyright (C) 2019 Leo Balter. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-asyncblockstart
|
||||||
|
description: >
|
||||||
|
Evaluation of await ticks order
|
||||||
|
info: |
|
||||||
|
AsyncBlockStart ( promiseCapability, asyncBody, asyncContext )
|
||||||
|
|
||||||
|
1. Assert: promiseCapability is a PromiseCapability Record.
|
||||||
|
2. Let runningContext be the running execution context.
|
||||||
|
3. Set the code evaluation state of asyncContext such that when evaluation is resumed for that execution context the following steps will be performed:
|
||||||
|
a. Let result be the result of evaluating asyncBody.
|
||||||
|
...
|
||||||
|
includes: [compareArray.js]
|
||||||
|
flags: [module, async]
|
||||||
|
features: [top-level-await]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var expected = [
|
||||||
|
'tick 1',
|
||||||
|
'await 1',
|
||||||
|
'tick 2',
|
||||||
|
'await 2',
|
||||||
|
'tick 3',
|
||||||
|
'await 3',
|
||||||
|
'tick 4',
|
||||||
|
'await 4',
|
||||||
|
];
|
||||||
|
|
||||||
|
var actual = [];
|
||||||
|
|
||||||
|
Promise.resolve(0)
|
||||||
|
.then(() => actual.push('tick 1'))
|
||||||
|
.then(() => actual.push('tick 2'))
|
||||||
|
.then(() => actual.push('tick 3'))
|
||||||
|
.then(() => actual.push('tick 4'))
|
||||||
|
.then(() => {
|
||||||
|
assert.compareArray(actual, expected, 'Ticks for top level await and promises');
|
||||||
|
}).then($DONE, $DONE);
|
||||||
|
|
||||||
|
await 1; actual.push('await 1');
|
||||||
|
await 2; actual.push('await 2');
|
||||||
|
await 3; actual.push('await 3');
|
||||||
|
await 4; actual.push('await 4');
|
35
test/language/module-code/top-level-await/void-await-expr.js
Normal file
35
test/language/module-code/top-level-await/void-await-expr.js
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
// Copyright (C) 2019 Leo Balter. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
description: >
|
||||||
|
void AwaitExpression is still evaluated
|
||||||
|
info: |
|
||||||
|
ModuleItem:
|
||||||
|
StatementListItem[~Yield, +Await, ~Return]
|
||||||
|
|
||||||
|
...
|
||||||
|
|
||||||
|
UnaryExpression[Yield, Await]
|
||||||
|
void UnaryExpression[?Yield, ?Await]
|
||||||
|
[+Await]AwaitExpression[?Yield]
|
||||||
|
|
||||||
|
AwaitExpression[Yield]:
|
||||||
|
await UnaryExpression[?Yield, +Await]
|
||||||
|
esid: prod-AwaitExpression
|
||||||
|
flags: [module, async]
|
||||||
|
features: [top-level-await]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var got = 0;
|
||||||
|
var x = {
|
||||||
|
get y() {
|
||||||
|
got += 1;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void await x.y;
|
||||||
|
|
||||||
|
assert.sameValue(got, 1);
|
||||||
|
|
||||||
|
$DONE();
|
@ -0,0 +1,48 @@
|
|||||||
|
// Copyright (C) 2019 Leo Balter. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
description: >
|
||||||
|
Evaluate Await expression for IfStatement
|
||||||
|
info: |
|
||||||
|
ModuleItem:
|
||||||
|
StatementListItem[~Yield, +Await, ~Return]
|
||||||
|
|
||||||
|
...
|
||||||
|
|
||||||
|
UnaryExpression[Yield, Await]
|
||||||
|
[+Await]AwaitExpression[?Yield]
|
||||||
|
|
||||||
|
AwaitExpression[Yield]:
|
||||||
|
await UnaryExpression[?Yield, +Await]
|
||||||
|
esid: prod-AwaitExpression
|
||||||
|
flags: [module, async]
|
||||||
|
features: [top-level-await]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var values = [];
|
||||||
|
var p = Promise.resolve().then(() => {
|
||||||
|
// Replaces p!
|
||||||
|
p = Promise.resolve().then(() => {
|
||||||
|
p = Promise.resolve().then(() => {
|
||||||
|
values.push(3);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
values.push(2);
|
||||||
|
return true;
|
||||||
|
})
|
||||||
|
|
||||||
|
values.push(1);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
while (await p) {}
|
||||||
|
|
||||||
|
assert.sameValue(values.length, 3);
|
||||||
|
assert.sameValue(values[0], 1);
|
||||||
|
assert.sameValue(values[1], 2);
|
||||||
|
assert.sameValue(values[2], 3);
|
||||||
|
|
||||||
|
$DONE();
|
Loading…
x
Reference in New Issue
Block a user