Update tests for top-level await

This commit is contained in:
Leo Balter 2019-08-07 13:12:52 -04:00 committed by Rick Waldron
parent 32bb36f5e4
commit 69bf8fb0f8
22 changed files with 311 additions and 272 deletions

View File

@ -2,23 +2,9 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Valid syntax for top level await.
desc: >
AwaitExpression ArrayLiteral
info: |
ModuleItem:
StatementListItem[~Yield, +Await, ~Return]
...
UnaryExpression[Yield, Await]
[+Await]AwaitExpression[?Yield]
AwaitExpression[Yield]:
await UnaryExpression[?Yield, +Await]
...
PrimaryExpression[Yield, Await]:
this
IdentifierReference[?Yield, ?Await]
@ -33,9 +19,8 @@ info: |
RegularExpressionLiteral
TemplateLiteral[?Yield, ?Await, ~Tagged]
CoverParenthesizedExpressionAndArrowParameterList[?Yield, ?Await]
esid: prod-AwaitExpression
flags: [module]
features: [top-level-await]
template: syntax
---*/
await [];
//- expr
await []

View File

@ -2,25 +2,13 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Valid syntax for top level await.
desc: >
AwaitExpression StringLiteral
info: |
ModuleItem:
StatementListItem[~Yield, +Await, ~Return]
...
ExpressionStatement[Yield, Await]:
[lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }]
Expression[+In, ?Yield, ?Await];
UnaryExpression[Yield, Await]
[+Await]AwaitExpression[?Yield]
AwaitExpression[Yield]:
await UnaryExpression[?Yield, +Await]
...
PrimaryExpression[Yield, Await]:
@ -37,9 +25,8 @@ info: |
RegularExpressionLiteral
TemplateLiteral[?Yield, ?Await, ~Tagged]
CoverParenthesizedExpressionAndArrowParameterList[?Yield, ?Await]
esid: prod-AwaitExpression
flags: [module]
features: [top-level-await]
template: syntax
---*/
await function() {};
//- expr
await function() {}

View File

@ -2,23 +2,9 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Valid syntax for top level await.
desc: >
AwaitExpression IdentifierReference
info: |
ModuleItem:
StatementListItem[~Yield, +Await, ~Return]
...
UnaryExpression[Yield, Await]
[+Await]AwaitExpression[?Yield]
AwaitExpression[Yield]:
await UnaryExpression[?Yield, +Await]
...
PrimaryExpression[Yield, Await]:
this
IdentifierReference[?Yield, ?Await]
@ -33,11 +19,10 @@ info: |
RegularExpressionLiteral
TemplateLiteral[?Yield, ?Await, ~Tagged]
CoverParenthesizedExpressionAndArrowParameterList[?Yield, ?Await]
esid: prod-AwaitExpression
flags: [module]
features: [top-level-await]
template: syntax
---*/
//- setup
var foo = 1;
await foo;
//- expr
await foo

View File

@ -2,23 +2,9 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Valid syntax for top level await.
desc: >
AwaitExpression NumberLiteral
info: |
ModuleItem:
StatementListItem[~Yield, +Await, ~Return]
...
UnaryExpression[Yield, Await]
[+Await]AwaitExpression[?Yield]
AwaitExpression[Yield]:
await UnaryExpression[?Yield, +Await]
...
PrimaryExpression[Yield, Await]:
this
IdentifierReference[?Yield, ?Await]
@ -33,9 +19,8 @@ info: |
RegularExpressionLiteral
TemplateLiteral[?Yield, ?Await, ~Tagged]
CoverParenthesizedExpressionAndArrowParameterList[?Yield, ?Await]
esid: prod-AwaitExpression
flags: [module]
features: [top-level-await]
template: syntax
---*/
await 1;
//- expr
await 1

View File

@ -2,23 +2,9 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Valid syntax for top level await.
desc: >
AwaitExpression StringLiteral
info: |
ModuleItem:
StatementListItem[~Yield, +Await, ~Return]
...
UnaryExpression[Yield, Await]
[+Await]AwaitExpression[?Yield]
AwaitExpression[Yield]:
await UnaryExpression[?Yield, +Await]
...
PrimaryExpression[Yield, Await]:
this
IdentifierReference[?Yield, ?Await]
@ -33,9 +19,8 @@ info: |
RegularExpressionLiteral
TemplateLiteral[?Yield, ?Await, ~Tagged]
CoverParenthesizedExpressionAndArrowParameterList[?Yield, ?Await]
esid: prod-AwaitExpression
flags: [module]
features: [top-level-await]
template: syntax
---*/
await '';
//- expr
await ''

View File

@ -2,15 +2,9 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Valid syntax for top level await.
desc: >
Nested AwaitExpressions
info: |
ModuleItem:
StatementListItem[~Yield, +Await, ~Return]
...
TryStatement[Yield, Await, Return]:
try Block[?Yield, ?Await, ?Return] Catch[?Yield, ?Await, ?Return]
try Block[?Yield, ?Await, ?Return] Finally[?Yield, ?Await, ?Return]
@ -21,15 +15,8 @@ info: |
ExpressionStatement[Yield, Await]:
[lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }]
Expression[+In, ?Yield, ?Await];
UnaryExpression[Yield, Await]
[+Await]AwaitExpression[?Yield]
AwaitExpression[Yield]:
await UnaryExpression[?Yield, +Await]
esid: prod-AwaitExpression
flags: [module]
features: [top-level-await]
template: syntax
---*/
await await await await await await await await await await await await await await await 'await';
//- expr
await await await await await await await await await await await await await await await 'await'

View File

@ -2,23 +2,9 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Valid syntax for top level await.
AwaitExpression ArrayLiteral
desc: >
AwaitExpression new MemberExpression
info: |
ModuleItem:
StatementListItem[~Yield, +Await, ~Return]
...
UnaryExpression[Yield, Await]
[+Await]AwaitExpression[?Yield]
AwaitExpression[Yield]:
await UnaryExpression[?Yield, +Await]
...
LeftHandSideExpression[Yield, Await]:
NewExpression[?Yield, ?Await]
CallExpression[?Yield, ?Await]
@ -30,9 +16,8 @@ info: |
MemberExpression[Yield, Await]:
...
new MemberExpression[?Yield, ?Await] Arguments[?Yield, ?Await]
esid: prod-AwaitExpression
flags: [module]
features: [top-level-await]
template: syntax
---*/
await new Promise(function(res, rej) { res(1); });
//- expr
await new Promise(function(res, rej) { res(1); })

View File

@ -2,23 +2,9 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Valid syntax for top level await.
desc: >
AwaitExpression NullLiteral
info: |
ModuleItem:
StatementListItem[~Yield, +Await, ~Return]
...
UnaryExpression[Yield, Await]
[+Await]AwaitExpression[?Yield]
AwaitExpression[Yield]:
await UnaryExpression[?Yield, +Await]
...
PrimaryExpression[Yield, Await]:
this
IdentifierReference[?Yield, ?Await]
@ -33,9 +19,8 @@ info: |
RegularExpressionLiteral
TemplateLiteral[?Yield, ?Await, ~Tagged]
CoverParenthesizedExpressionAndArrowParameterList[?Yield, ?Await]
esid: prod-AwaitExpression
flags: [module]
features: [top-level-await]
template: syntax
---*/
await null;
//- expr
await null

View File

@ -2,23 +2,9 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Valid syntax for top level await.
desc: >
AwaitExpression ObjectLiteral
info: |
ModuleItem:
StatementListItem[~Yield, +Await, ~Return]
...
UnaryExpression[Yield, Await]
[+Await]AwaitExpression[?Yield]
AwaitExpression[Yield]:
await UnaryExpression[?Yield, +Await]
...
PrimaryExpression[Yield, Await]:
this
IdentifierReference[?Yield, ?Await]
@ -33,12 +19,10 @@ info: |
RegularExpressionLiteral
TemplateLiteral[?Yield, ?Await, ~Tagged]
CoverParenthesizedExpressionAndArrowParameterList[?Yield, ?Await]
esid: prod-AwaitExpression
flags: [module]
features: [top-level-await]
template: syntax
---*/
// This syntax helps avoiding the code being parsed as a Block
await { function() {} };
// Yes, it's a MethodDefinition...
//- expr
await { function() {} }

View File

@ -2,23 +2,9 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Valid syntax for top level await.
desc: >
AwaitExpression RegularExpressionLiteral
info: |
ModuleItem:
StatementListItem[~Yield, +Await, ~Return]
...
UnaryExpression[Yield, Await]
[+Await]AwaitExpression[?Yield]
AwaitExpression[Yield]:
await UnaryExpression[?Yield, +Await]
...
PrimaryExpression[Yield, Await]:
this
IdentifierReference[?Yield, ?Await]
@ -33,9 +19,8 @@ info: |
RegularExpressionLiteral
TemplateLiteral[?Yield, ?Await, ~Tagged]
CoverParenthesizedExpressionAndArrowParameterList[?Yield, ?Await]
esid: prod-AwaitExpression
flags: [module]
features: [top-level-await]
template: syntax
---*/
await /1/;
//- expr
await /1/

View File

@ -2,23 +2,9 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Valid syntax for top level await.
desc: >
AwaitExpression TemplateLiteral
info: |
ModuleItem:
StatementListItem[~Yield, +Await, ~Return]
...
UnaryExpression[Yield, Await]
[+Await]AwaitExpression[?Yield]
AwaitExpression[Yield]:
await UnaryExpression[?Yield, +Await]
...
PrimaryExpression[Yield, Await]:
this
IdentifierReference[?Yield, ?Await]
@ -33,10 +19,9 @@ info: |
RegularExpressionLiteral
TemplateLiteral[?Yield, ?Await, ~Tagged]
CoverParenthesizedExpressionAndArrowParameterList[?Yield, ?Await]
esid: prod-AwaitExpression
flags: [module]
features: [top-level-await]
template: syntax
---*/
await ``;
//- expr
await ``

View File

@ -2,23 +2,9 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Valid syntax for top level await.
desc: >
AwaitExpression this
info: |
ModuleItem:
StatementListItem[~Yield, +Await, ~Return]
...
UnaryExpression[Yield, Await]
[+Await]AwaitExpression[?Yield]
AwaitExpression[Yield]:
await UnaryExpression[?Yield, +Await]
...
PrimaryExpression[Yield, Await]:
this
IdentifierReference[?Yield, ?Await]
@ -33,9 +19,8 @@ info: |
RegularExpressionLiteral
TemplateLiteral[?Yield, ?Await, ~Tagged]
CoverParenthesizedExpressionAndArrowParameterList[?Yield, ?Await]
esid: prod-AwaitExpression
flags: [module]
features: [top-level-await]
template: syntax
---*/
await this;
//- expr
await this

View File

@ -2,37 +2,22 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Valid syntax for top level await. It propagates to the StatementList of a Block
path: language/module-code/top-level-await/syntax/block-
name: Valid syntax for top level await in a block.
esid: prod-AwaitExpression
info: |
ModuleItem:
StatementListItem[~Yield, +Await, ~Return]
StatementListItem[Yield, Await, Return]:
Statement[?Yield, ?Await, ?Return]
Declaration[?Yield, ?Await]
Statement[Yield, Await, Return]:
BlockStatement[?Yield, ?Await, ?Return]
BlockStatement[Yield, Await, Return]:
Block[?Yield, ?Await, ?Return]
Block[Yield, Await, Return]:
{ StatementList[?Yield, ?Await, ?Return]_opt }
...
ExpressionStatement[Yield, Await]:
[lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }]
Expression[+In, ?Yield, ?Await];
UnaryExpression[Yield, Await]
[+Await]AwaitExpression[?Yield]
AwaitExpression[Yield]:
await UnaryExpression[?Yield, +Await]
esid: prod-AwaitExpression
...
flags: [module]
features: [top-level-await]
---*/
@ -54,7 +39,7 @@ features: [top-level-await]
{
{
{
await {};
/*{ expr }*/;
}
}
}

View File

@ -0,0 +1,50 @@
// 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-await-
name: Valid syntax for top level await in for await statements.
esid: prod-AwaitExpression
info: |
ModuleItem:
StatementListItem[~Yield, +Await, ~Return]
...
IterationStatement[Yield, Await, Return]:
[+Await]for await ( [lookahead ≠ let] LeftHandSideExpression[?Yield, ?Await] of AssignmentExpression[+In, ?Yield, ?Await] ) Statement[?Yield, ?Await, ?Return]
[+Await]for await ( var ForBinding[?Yield, ?Await] of AssignmentExpression[+In, ?Yield, ?Await] ) Statement[?Yield, ?Await, ?Return]
[+Await]for await ( ForDeclaration[?Yield, ?Await] of AssignmentExpression[+In, ?Yield, ?Await] ) Statement[?Yield, ?Await, ?Return]
...
UnaryExpression[Yield, Await]
[+Await]AwaitExpression[?Yield]
AwaitExpression[Yield]:
await UnaryExpression[?Yield, +Await]
...
flags: [module]
features: [top-level-await, async-iteration]
---*/
var binding;
// [+Await]for await ( [lookahead ≠ let] LeftHandSideExpression[?Yield, ?Await] of AssignmentExpression[+In, ?Yield, ?Await] ) Statement[?Yield, ?Await, ?Return]
for await (binding of [/*{ expr }*/]) {
/*{ expr }*/;
break;
}
// [+Await]for await ( var ForBinding[?Yield, ?Await] of AssignmentExpression[+In, ?Yield, ?Await] ) Statement[?Yield, ?Await, ?Return]
for await (var binding of [/*{ expr }*/]) {
/*{ expr }*/;
break;
}
// [+Await]for await ( ForDeclaration[?Yield, ?Await] of AssignmentExpression[+In, ?Yield, ?Await] ) Statement[?Yield, ?Await, ?Return]
for await (let binding of [/*{ expr }*/]) {
/*{ expr }*/;
break;
}

View File

@ -2,9 +2,9 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Valid syntax for top level await.
IfStatement ( AwaitExpression BooleanLiteral )
path: language/module-code/top-level-await/syntax/if-block-
name: Valid syntax for top level await in an if expression position.
esid: prod-AwaitExpression
info: |
ModuleItem:
StatementListItem[~Yield, +Await, ~Return]
@ -17,18 +17,17 @@ info: |
...
ExpressionStatement[Yield, Await]:
[lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }]
Expression[+In, ?Yield, ?Await];
UnaryExpression[Yield, Await]
[+Await]AwaitExpression[?Yield]
AwaitExpression[Yield]:
await UnaryExpression[?Yield, +Await]
esid: prod-AwaitExpression
...
flags: [module]
features: [top-level-await]
---*/
if (await false) {};
if (true) {
/*{ expr }*/;
}

View File

@ -0,0 +1,31 @@
// 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/if-expr-
name: Valid syntax for top level await in an if expression position.
esid: prod-AwaitExpression
info: |
ModuleItem:
StatementListItem[~Yield, +Await, ~Return]
...
IfStatement[Yield, Await, Return]:
if(Expression[+In, ?Yield, ?Await])Statement[?Yield, ?Await, ?Return]elseStatement[?Yield, ?Await, ?Return]
if(Expression[+In, ?Yield, ?Await])Statement[?Yield, ?Await, ?Return]
...
UnaryExpression[Yield, Await]
[+Await]AwaitExpression[?Yield]
AwaitExpression[Yield]:
await UnaryExpression[?Yield, +Await]
...
flags: [module]
features: [top-level-await]
---*/
if (/*{ expr }*/) {}

View File

@ -0,0 +1,25 @@
// 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/top-level-
name: Valid syntax for top level await.
esid: prod-AwaitExpression
info: |
ModuleItem:
StatementListItem[~Yield, +Await, ~Return]
...
UnaryExpression[Yield, Await]
[+Await]AwaitExpression[?Yield]
AwaitExpression[Yield]:
await UnaryExpression[?Yield, +Await]
...
flags: [module]
features: [top-level-await]
---*/
/*{ expr }*/;

View File

@ -2,9 +2,9 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Valid syntax for top level await. It propagates to nested blocks
TryStatement with AwaitExpression
path: language/module-code/top-level-await/syntax/try-
name: Valid syntax for top level await in try-catch-finally blocks.
esid: prod-AwaitExpression
info: |
ModuleItem:
StatementListItem[~Yield, +Await, ~Return]
@ -18,36 +18,33 @@ info: |
...
ExpressionStatement[Yield, Await]:
[lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }]
Expression[+In, ?Yield, ?Await];
UnaryExpression[Yield, Await]
[+Await]AwaitExpression[?Yield]
AwaitExpression[Yield]:
await UnaryExpression[?Yield, +Await]
esid: prod-AwaitExpression
...
flags: [module]
features: [top-level-await]
---*/
try {
await 0;
/*{ expr }*/;
} catch(e) {
await 1;
/*{ expr }*/;
}
try {
await 0;
/*{ expr }*/;
} finally {
await 1;
/*{ expr }*/;
}
try {
await 0;
/*{ expr }*/;
} catch(e) {
await 1;
/*{ expr }*/;
} finally {
await 2;
/*{ expr }*/;
}

View 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/module-code/top-level-await/syntax/typeof-
name: Valid syntax for top level await in an UnaryExpression (void).
esid: prod-AwaitExpression
info: |
ModuleItem:
StatementListItem[~Yield, +Await, ~Return]
...
UnaryExpression[Yield, Await]
typeof UnaryExpression[?Yield, ?Await]
[+Await]AwaitExpression[?Yield]
AwaitExpression[Yield]:
await UnaryExpression[?Yield, +Await]
...
flags: [module]
features: [top-level-await]
---*/
typeof /*{ expr }*/;

View 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/module-code/top-level-await/syntax/void-
name: Valid syntax for top level await in an UnaryExpression (void).
esid: prod-AwaitExpression
info: |
ModuleItem:
StatementListItem[~Yield, +Await, ~Return]
...
UnaryExpression[Yield, Await]
void UnaryExpression[?Yield, ?Await]
[+Await]AwaitExpression[?Yield]
AwaitExpression[Yield]:
await UnaryExpression[?Yield, +Await]
...
flags: [module]
features: [top-level-await]
---*/
void /*{ expr }*/;

View 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.
/*---
path: language/module-code/top-level-await/syntax/while-
name: Valid syntax for top level await in an while expression position.
esid: prod-AwaitExpression
info: |
ModuleItem:
StatementListItem[~Yield, +Await, ~Return]
...
IterationStatement[Yield, Await, Return]:
while ( Expression[+In, ?Yield, ?Await] ) Statement[?Yield, ?Await, ?Return]
...
UnaryExpression[Yield, Await]
[+Await]AwaitExpression[?Yield]
AwaitExpression[Yield]:
await UnaryExpression[?Yield, +Await]
...
flags: [module]
features: [top-level-await]
---*/
while (/*{ expr }*/) { break; }

View 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.
/*---
description: >
Valid syntax for top level await.
AwaitExpression ImportCall
info: |
ModuleItem:
StatementListItem[~Yield, +Await, ~Return]
...
UnaryExpression[Yield, Await]
[+Await]AwaitExpression[?Yield]
AwaitExpression[Yield]:
await UnaryExpression[?Yield, +Await]
...
TryStatement[Yield, Await, Return]:
try Block[?Yield, ?Await, ?Return] Catch[?Yield, ?Await, ?Return]
try Block[?Yield, ?Await, ?Return] Finally[?Yield, ?Await, ?Return]
try Block[?Yield, ?Await, ?Return] Catch[?Yield, ?Await, ?Return] Finally[?Yield, ?Await, ?Return]
Catch[Yield, Await, Return]:
catch(CatchParameter[?Yield, ?Await])Block[?Yield, ?Await, ?Return]
catchBlock[?Yield, ?Await, ?Return]
Finally[Yield, Await, Return]:
finallyBlock[?Yield, ?Await, ?Return]
CatchParameter[Yield, Await]:
BindingIdentifier[?Yield, ?Await]
BindingPattern[?Yield, ?Await]
esid: prod-AwaitExpression
flags: [module]
features: [top-level-await, dynamic-import]
---*/
try {} catch (await e) {}
try {} catch (await {}) {}
try {} catch (await { x: await 42 }) {} // BindingElement
try {} catch (await { x = await 42 }) {} // Initializer
try {} catch (await []) {}
try {} catch (await [ x = await 42 ]) {}