mirror of
				https://github.com/tc39/test262.git
				synced 2025-10-31 11:44:31 +01:00 
			
		
		
		
	First set of tests for Top Level Await
This commit is contained in:
		
							parent
							
								
									84cff5090e
								
							
						
					
					
						commit
						56a2dba975
					
				| @ -137,6 +137,10 @@ FinalizationGroup | ||||
| # https://github.com/tc39/proposal-optional-chaining | ||||
| optional-chaining | ||||
| 
 | ||||
| # Top Level Await | ||||
| # https://github.com/tc39/proposal-top-level-await | ||||
| top-level-await | ||||
| 
 | ||||
| ## Standard language features | ||||
| # | ||||
| # Language features that have been included in a published version of the | ||||
|  | ||||
| @ -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.
 | ||||
| 
 | ||||
| /*--- | ||||
| description: > | ||||
|   A function after top level await is an expression and not a hoistable declaration | ||||
| 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]: | ||||
|     this | ||||
|     IdentifierReference[?Yield, ?Await] | ||||
|     Literal | ||||
|     ArrayLiteral[?Yield, ?Await] | ||||
|     ObjectLiteral[?Yield, ?Await] | ||||
|     FunctionExpression | ||||
|     ClassExpression[?Yield, ?Await] | ||||
|     GeneratorExpression | ||||
|     AsyncFunctionExpression | ||||
|     AsyncGeneratorExpression | ||||
|     RegularExpressionLiteral | ||||
|     TemplateLiteral[?Yield, ?Await, ~Tagged] | ||||
|     CoverParenthesizedExpressionAndArrowParameterList[?Yield, ?Await] | ||||
| esid: prod-AwaitExpression | ||||
| flags: [module, async] | ||||
| features: [top-level-await] | ||||
| ---*/ | ||||
| 
 | ||||
| function fn() { return 1; } | ||||
| function fn() { return 2; } | ||||
| await function fn() { return 3; }; | ||||
| 
 | ||||
| assert.sameValue(fn(), 2); | ||||
| 
 | ||||
| $DONE(); | ||||
| @ -0,0 +1,56 @@ | ||||
| // Copyright (C) 2019 Leo Balter. All rights reserved.
 | ||||
| // This code is governed by the BSD license found in the LICENSE file.
 | ||||
| 
 | ||||
| /*--- | ||||
| description: > | ||||
|   Verify a RegularExpressionLiteral following an AwaitExpression is | ||||
|   not ambiguous to an Division | ||||
| 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] | ||||
|     Literal | ||||
|     ArrayLiteral[?Yield, ?Await] | ||||
|     ObjectLiteral[?Yield, ?Await] | ||||
|     FunctionExpression | ||||
|     ClassExpression[?Yield, ?Await] | ||||
|     GeneratorExpression | ||||
|     AsyncFunctionExpression | ||||
|     AsyncGeneratorExpression | ||||
|     RegularExpressionLiteral | ||||
|     TemplateLiteral[?Yield, ?Await, ~Tagged] | ||||
|     CoverParenthesizedExpressionAndArrowParameterList[?Yield, ?Await] | ||||
| esid: prod-AwaitExpression | ||||
| flags: [module, async] | ||||
| features: [top-level-await] | ||||
| ---*/ | ||||
| 
 | ||||
| var lol = false; | ||||
| var x = { | ||||
|   get y() { | ||||
|     lol = true; | ||||
|   } | ||||
| }; | ||||
| 
 | ||||
| var g = 42; | ||||
| 
 | ||||
| await /x.y/g; | ||||
| 
 | ||||
| if (lol) { | ||||
|   $DONE('It should be a RegExp'); | ||||
| } else { | ||||
|   $DONE(); | ||||
| } | ||||
| @ -0,0 +1,41 @@ | ||||
| // 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 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] | ||||
|     Literal | ||||
|     ArrayLiteral[?Yield, ?Await] | ||||
|     ObjectLiteral[?Yield, ?Await] | ||||
|     FunctionExpression | ||||
|     ClassExpression[?Yield, ?Await] | ||||
|     GeneratorExpression | ||||
|     AsyncFunctionExpression | ||||
|     AsyncGeneratorExpression | ||||
|     RegularExpressionLiteral | ||||
|     TemplateLiteral[?Yield, ?Await, ~Tagged] | ||||
|     CoverParenthesizedExpressionAndArrowParameterList[?Yield, ?Await] | ||||
| esid: prod-AwaitExpression | ||||
| flags: [module] | ||||
| features: [top-level-await] | ||||
| ---*/ | ||||
| 
 | ||||
| await []; | ||||
| @ -0,0 +1,41 @@ | ||||
| // 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] | ||||
| 
 | ||||
|   ... | ||||
| 
 | ||||
|   LeftHandSideExpression[Yield, Await]: | ||||
|     NewExpression[?Yield, ?Await] | ||||
|     CallExpression[?Yield, ?Await] | ||||
| 
 | ||||
|   CallExpression[Yield, Await]: | ||||
|     ImportCall[?Yield, ?Await] | ||||
| 
 | ||||
|   ImportCall[Yield, Await]: | ||||
|     import ( AssignmentExpression[+In, ?Yield, ?Await] ) | ||||
| esid: prod-AwaitExpression | ||||
| flags: [module] | ||||
| features: [top-level-await, dynamic-import] | ||||
| ---*/ | ||||
| 
 | ||||
| try { | ||||
|   await import('foo'); | ||||
| } catch (e) { | ||||
|   // Ignore errors, we are just checking if the syntax is valid and
 | ||||
|   // we should not worry if a module was loaded.
 | ||||
| } | ||||
| @ -0,0 +1,45 @@ | ||||
| // 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 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]: | ||||
|     this | ||||
|     IdentifierReference[?Yield, ?Await] | ||||
|     Literal | ||||
|     ArrayLiteral[?Yield, ?Await] | ||||
|     ObjectLiteral[?Yield, ?Await] | ||||
|     FunctionExpression | ||||
|     ClassExpression[?Yield, ?Await] | ||||
|     GeneratorExpression | ||||
|     AsyncFunctionExpression | ||||
|     AsyncGeneratorExpression | ||||
|     RegularExpressionLiteral | ||||
|     TemplateLiteral[?Yield, ?Await, ~Tagged] | ||||
|     CoverParenthesizedExpressionAndArrowParameterList[?Yield, ?Await] | ||||
| esid: prod-AwaitExpression | ||||
| flags: [module] | ||||
| features: [top-level-await] | ||||
| ---*/ | ||||
| 
 | ||||
| await function() {}; | ||||
| @ -0,0 +1,43 @@ | ||||
| // 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 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] | ||||
|     Literal | ||||
|     ArrayLiteral[?Yield, ?Await] | ||||
|     ObjectLiteral[?Yield, ?Await] | ||||
|     FunctionExpression | ||||
|     ClassExpression[?Yield, ?Await] | ||||
|     GeneratorExpression | ||||
|     AsyncFunctionExpression | ||||
|     AsyncGeneratorExpression | ||||
|     RegularExpressionLiteral | ||||
|     TemplateLiteral[?Yield, ?Await, ~Tagged] | ||||
|     CoverParenthesizedExpressionAndArrowParameterList[?Yield, ?Await] | ||||
| esid: prod-AwaitExpression | ||||
| flags: [module] | ||||
| features: [top-level-await] | ||||
| ---*/ | ||||
| 
 | ||||
| var foo = 1; | ||||
| 
 | ||||
| await foo; | ||||
| @ -0,0 +1,41 @@ | ||||
| // 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 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] | ||||
|     Literal | ||||
|     ArrayLiteral[?Yield, ?Await] | ||||
|     ObjectLiteral[?Yield, ?Await] | ||||
|     FunctionExpression | ||||
|     ClassExpression[?Yield, ?Await] | ||||
|     GeneratorExpression | ||||
|     AsyncFunctionExpression | ||||
|     AsyncGeneratorExpression | ||||
|     RegularExpressionLiteral | ||||
|     TemplateLiteral[?Yield, ?Await, ~Tagged] | ||||
|     CoverParenthesizedExpressionAndArrowParameterList[?Yield, ?Await] | ||||
| esid: prod-AwaitExpression | ||||
| flags: [module] | ||||
| features: [top-level-await] | ||||
| ---*/ | ||||
| 
 | ||||
| await 1; | ||||
| @ -0,0 +1,41 @@ | ||||
| // 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 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] | ||||
|     Literal | ||||
|     ArrayLiteral[?Yield, ?Await] | ||||
|     ObjectLiteral[?Yield, ?Await] | ||||
|     FunctionExpression | ||||
|     ClassExpression[?Yield, ?Await] | ||||
|     GeneratorExpression | ||||
|     AsyncFunctionExpression | ||||
|     AsyncGeneratorExpression | ||||
|     RegularExpressionLiteral | ||||
|     TemplateLiteral[?Yield, ?Await, ~Tagged] | ||||
|     CoverParenthesizedExpressionAndArrowParameterList[?Yield, ?Await] | ||||
| esid: prod-AwaitExpression | ||||
| flags: [module] | ||||
| features: [top-level-await] | ||||
| ---*/ | ||||
| 
 | ||||
| await ''; | ||||
| @ -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: > | ||||
|   Valid syntax for top level await. | ||||
|   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] | ||||
|     try Block[?Yield, ?Await, ?Return] Catch[?Yield, ?Await, ?Return] Finally[?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] | ||||
| esid: prod-AwaitExpression | ||||
| flags: [module] | ||||
| features: [top-level-await] | ||||
| ---*/ | ||||
| 
 | ||||
| await await await await await await await await await await await await await await await 'await'; | ||||
| @ -0,0 +1,41 @@ | ||||
| // 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 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] | ||||
|     Literal | ||||
|     ArrayLiteral[?Yield, ?Await] | ||||
|     ObjectLiteral[?Yield, ?Await] | ||||
|     FunctionExpression | ||||
|     ClassExpression[?Yield, ?Await] | ||||
|     GeneratorExpression | ||||
|     AsyncFunctionExpression | ||||
|     AsyncGeneratorExpression | ||||
|     RegularExpressionLiteral | ||||
|     TemplateLiteral[?Yield, ?Await, ~Tagged] | ||||
|     CoverParenthesizedExpressionAndArrowParameterList[?Yield, ?Await] | ||||
| esid: prod-AwaitExpression | ||||
| flags: [module] | ||||
| features: [top-level-await] | ||||
| ---*/ | ||||
| 
 | ||||
| await null; | ||||
| @ -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.
 | ||||
| 
 | ||||
| /*--- | ||||
| description: > | ||||
|   Valid syntax for top level await. | ||||
|   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] | ||||
|     Literal | ||||
|     ArrayLiteral[?Yield, ?Await] | ||||
|     ObjectLiteral[?Yield, ?Await] | ||||
|     FunctionExpression | ||||
|     ClassExpression[?Yield, ?Await] | ||||
|     GeneratorExpression | ||||
|     AsyncFunctionExpression | ||||
|     AsyncGeneratorExpression | ||||
|     RegularExpressionLiteral | ||||
|     TemplateLiteral[?Yield, ?Await, ~Tagged] | ||||
|     CoverParenthesizedExpressionAndArrowParameterList[?Yield, ?Await] | ||||
| esid: prod-AwaitExpression | ||||
| flags: [module] | ||||
| features: [top-level-await] | ||||
| ---*/ | ||||
| 
 | ||||
| // This syntax helps avoiding the code being parsed as a Block
 | ||||
| await { function() {} }; | ||||
| 
 | ||||
| // Yes, it's a MethodDefinition...
 | ||||
| @ -0,0 +1,41 @@ | ||||
| // 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 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] | ||||
|     Literal | ||||
|     ArrayLiteral[?Yield, ?Await] | ||||
|     ObjectLiteral[?Yield, ?Await] | ||||
|     FunctionExpression | ||||
|     ClassExpression[?Yield, ?Await] | ||||
|     GeneratorExpression | ||||
|     AsyncFunctionExpression | ||||
|     AsyncGeneratorExpression | ||||
|     RegularExpressionLiteral | ||||
|     TemplateLiteral[?Yield, ?Await, ~Tagged] | ||||
|     CoverParenthesizedExpressionAndArrowParameterList[?Yield, ?Await] | ||||
| esid: prod-AwaitExpression | ||||
| flags: [module] | ||||
| features: [top-level-await] | ||||
| ---*/ | ||||
| 
 | ||||
| await /1/; | ||||
| @ -0,0 +1,42 @@ | ||||
| // 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 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] | ||||
|     Literal | ||||
|     ArrayLiteral[?Yield, ?Await] | ||||
|     ObjectLiteral[?Yield, ?Await] | ||||
|     FunctionExpression | ||||
|     ClassExpression[?Yield, ?Await] | ||||
|     GeneratorExpression | ||||
|     AsyncFunctionExpression | ||||
|     AsyncGeneratorExpression | ||||
|     RegularExpressionLiteral | ||||
|     TemplateLiteral[?Yield, ?Await, ~Tagged] | ||||
|     CoverParenthesizedExpressionAndArrowParameterList[?Yield, ?Await] | ||||
| esid: prod-AwaitExpression | ||||
| flags: [module] | ||||
| features: [top-level-await] | ||||
| ---*/ | ||||
| 
 | ||||
| await ``; | ||||
| 
 | ||||
| @ -0,0 +1,41 @@ | ||||
| // 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 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] | ||||
|     Literal | ||||
|     ArrayLiteral[?Yield, ?Await] | ||||
|     ObjectLiteral[?Yield, ?Await] | ||||
|     FunctionExpression | ||||
|     ClassExpression[?Yield, ?Await] | ||||
|     GeneratorExpression | ||||
|     AsyncFunctionExpression | ||||
|     AsyncGeneratorExpression | ||||
|     RegularExpressionLiteral | ||||
|     TemplateLiteral[?Yield, ?Await, ~Tagged] | ||||
|     CoverParenthesizedExpressionAndArrowParameterList[?Yield, ?Await] | ||||
| esid: prod-AwaitExpression | ||||
| flags: [module] | ||||
| features: [top-level-await] | ||||
| ---*/ | ||||
| 
 | ||||
| await this; | ||||
| @ -0,0 +1,74 @@ | ||||
| // 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. It propagates to the StatementList of a Block | ||||
| 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] | ||||
| ---*/ | ||||
| 
 | ||||
| { | ||||
|   { | ||||
|     { | ||||
|       { | ||||
|         { | ||||
|           { | ||||
|             { | ||||
|               { | ||||
|                 { | ||||
|                   { | ||||
|                     { | ||||
|                       { | ||||
|                         { | ||||
|                           { | ||||
|                             { | ||||
|                               { | ||||
|                                 { | ||||
|                                   await {}; | ||||
|                                 } | ||||
|                               } | ||||
|                             } | ||||
|                           } | ||||
|                         } | ||||
|                       } | ||||
|                     } | ||||
|                   } | ||||
|                 } | ||||
|               } | ||||
|             } | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|   } | ||||
| } | ||||
| @ -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.
 | ||||
| 
 | ||||
| /*--- | ||||
| description: > | ||||
|   The Await capability does not propagate to the body of a function declaration | ||||
| info: | | ||||
|   ModuleItem: | ||||
|     StatementListItem[~Yield, +Await, ~Return] | ||||
| 
 | ||||
|   StatementListItem[Yield, Await, Return]: | ||||
|     Statement[?Yield, ?Await, ?Return] | ||||
|     Declaration[?Yield, ?Await] | ||||
| 
 | ||||
|   Declaration[Yield, Await]: | ||||
|     HoistableDeclaration[?Yield, ?Await, ~Default] | ||||
|     ClassDeclaration[?Yield, ?Await, ~Default] | ||||
|     LexicalDeclaration[+In, ?Yield, ?Await] | ||||
| 
 | ||||
|   HoistableDeclaration[Yield, Await, Default]: | ||||
|     FunctionDeclaration[?Yield, ?Await, ?Default] | ||||
|     GeneratorDeclaration[?Yield, ?Await, ?Default] | ||||
|     AsyncFunctionDeclaration[?Yield, ?Await, ?Default] | ||||
|     AsyncGeneratorDeclaration[?Yield, ?Await, ?Default] | ||||
| 
 | ||||
|   FunctionDeclaration[Yield, Await, Default]: | ||||
|     function BindingIdentifier[?Yield, ?Await] ( FormalParameters[~Yield, ~Await] ) { FunctionBody[~Yield, ~Await] } | ||||
| negative: | ||||
|   phase: parse | ||||
|   type: SyntaxError | ||||
| esid: prod-ModuleItem | ||||
| flags: [module] | ||||
| features: [top-level-await] | ||||
| ---*/ | ||||
| 
 | ||||
| $DONOTEVALUATE(); | ||||
| 
 | ||||
| function fn() { await 0; } | ||||
| @ -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.
 | ||||
| 
 | ||||
| /*--- | ||||
| description: > | ||||
|   The Await capability does not propagate to the parameters of a function declaration | ||||
| info: | | ||||
|   ModuleItem: | ||||
|     StatementListItem[~Yield, +Await, ~Return] | ||||
| 
 | ||||
|   StatementListItem[Yield, Await, Return]: | ||||
|     Statement[?Yield, ?Await, ?Return] | ||||
|     Declaration[?Yield, ?Await] | ||||
| 
 | ||||
|   Declaration[Yield, Await]: | ||||
|     HoistableDeclaration[?Yield, ?Await, ~Default] | ||||
|     ClassDeclaration[?Yield, ?Await, ~Default] | ||||
|     LexicalDeclaration[+In, ?Yield, ?Await] | ||||
| 
 | ||||
|   HoistableDeclaration[Yield, Await, Default]: | ||||
|     FunctionDeclaration[?Yield, ?Await, ?Default] | ||||
|     GeneratorDeclaration[?Yield, ?Await, ?Default] | ||||
|     AsyncFunctionDeclaration[?Yield, ?Await, ?Default] | ||||
|     AsyncGeneratorDeclaration[?Yield, ?Await, ?Default] | ||||
| 
 | ||||
|   FunctionDeclaration[Yield, Await, Default]: | ||||
|     function BindingIdentifier[?Yield, ?Await] ( FormalParameters[~Yield, ~Await] ) { FunctionBody[~Yield, ~Await] } | ||||
| negative: | ||||
|   phase: parse | ||||
|   type: SyntaxError | ||||
| esid: prod-ModuleItem | ||||
| flags: [module] | ||||
| features: [top-level-await] | ||||
| ---*/ | ||||
| 
 | ||||
| $DONOTEVALUATE(); | ||||
| 
 | ||||
| function fn(x = await 1) { | ||||
|   return x; | ||||
| } | ||||
| @ -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.
 | ||||
| 
 | ||||
| /*--- | ||||
| description: > | ||||
|   The Await capability does not propagate to the body of a function expression | ||||
| info: | | ||||
|   ModuleItem: | ||||
|     StatementListItem[~Yield, +Await, ~Return] | ||||
| 
 | ||||
|   StatementListItem[Yield, Await, Return]: | ||||
|     Statement[?Yield, ?Await, ?Return] | ||||
|     Declaration[?Yield, ?Await] | ||||
| 
 | ||||
|   FunctionExpression: | ||||
|     function BindingIdentifier[~Yield, ~Await]_opt ( FormalParameters[~Yield, ~Await] ) | ||||
|       { FunctionBody[~Yield, ~Await] } | ||||
| negative: | ||||
|   phase: parse | ||||
|   type: SyntaxError | ||||
| esid: prod-ModuleItem | ||||
| flags: [module] | ||||
| features: [top-level-await] | ||||
| ---*/ | ||||
| 
 | ||||
| $DONOTEVALUATE(); | ||||
| 
 | ||||
| 0, function () { | ||||
|   await 1; | ||||
| }; | ||||
| @ -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.
 | ||||
| 
 | ||||
| /*--- | ||||
| description: > | ||||
|   The Await capability does not propagate to the parameters of a function expression | ||||
| info: | | ||||
|   ModuleItem: | ||||
|     StatementListItem[~Yield, +Await, ~Return] | ||||
| 
 | ||||
|   StatementListItem[Yield, Await, Return]: | ||||
|     Statement[?Yield, ?Await, ?Return] | ||||
|     Declaration[?Yield, ?Await] | ||||
| 
 | ||||
|   FunctionExpression: | ||||
|     function BindingIdentifier[~Yield, ~Await]_opt ( FormalParameters[~Yield, ~Await] ) | ||||
|       { FunctionBody[~Yield, ~Await] } | ||||
| negative: | ||||
|   phase: parse | ||||
|   type: SyntaxError | ||||
| esid: prod-ModuleItem | ||||
| flags: [module] | ||||
| features: [top-level-await] | ||||
| ---*/ | ||||
| 
 | ||||
| $DONOTEVALUATE(); | ||||
| 
 | ||||
| 0, function (x = await 1) { | ||||
|   return x; | ||||
| }; | ||||
| @ -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.
 | ||||
| 
 | ||||
| /*--- | ||||
| description: > | ||||
|   The await keyword can't be escaped | ||||
| info: | | ||||
|   ModuleItem: | ||||
|     StatementListItem[~Yield, +Await, ~Return] | ||||
| 
 | ||||
|   ... | ||||
| 
 | ||||
|   AwaitExpression[Yield]: | ||||
|     await UnaryExpression[?Yield, +Await] | ||||
| negative: | ||||
|   phase: parse | ||||
|   type: SyntaxError | ||||
| esid: prod-ModuleItem | ||||
| flags: [module] | ||||
| features: [top-level-await] | ||||
| ---*/ | ||||
| 
 | ||||
| $DONOTEVALUATE(); | ||||
| 
 | ||||
| \u0061wait 0; | ||||
| @ -0,0 +1,34 @@ | ||||
| // 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. | ||||
|   IfStatement ( AwaitExpression BooleanLiteral ) | ||||
| 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] | ||||
| 
 | ||||
|   ... | ||||
| 
 | ||||
|   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) {}; | ||||
| @ -0,0 +1,53 @@ | ||||
| // 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. It propagates to nested blocks | ||||
|   TryStatement with AwaitExpression | ||||
| 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] | ||||
|     try Block[?Yield, ?Await, ?Return] Catch[?Yield, ?Await, ?Return] Finally[?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] | ||||
| esid: prod-AwaitExpression | ||||
| flags: [module] | ||||
| features: [top-level-await] | ||||
| ---*/ | ||||
| 
 | ||||
| try { | ||||
|   await 0; | ||||
| } catch(e) { | ||||
|   await 1; | ||||
| } | ||||
| 
 | ||||
| try { | ||||
|   await 0; | ||||
| } finally { | ||||
|   await 1; | ||||
| } | ||||
| 
 | ||||
| try { | ||||
|   await 0; | ||||
| } catch(e) { | ||||
|   await 1; | ||||
| } finally { | ||||
|   await 2; | ||||
| } | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user