diff --git a/test/language/module-code/top-level-await/new-await-parens.js b/test/language/module-code/top-level-await/new-await-parens.js new file mode 100644 index 0000000000..c8ef578038 --- /dev/null +++ b/test/language/module-code/top-level-await/new-await-parens.js @@ -0,0 +1,19 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-AwaitExpression +description: > + `new (await Constructor)` returns instance of Constructor +flags: [module, async] +features: [top-level-await] +---*/ + +assert.sameValue((new (await Number)).valueOf(), 0); +assert.sameValue((new (await String)).valueOf(), ''); +assert.sameValue((new (await Boolean)).valueOf(), false); +assert.sameValue((new (await Array)).length, 0); +assert.sameValue((new (await Map)).size, 0); +assert.sameValue((new (await Set)).size, 0); + +$DONE(); diff --git a/test/language/module-code/top-level-await/new-await-script-code.js b/test/language/module-code/top-level-await/new-await-script-code.js new file mode 100644 index 0000000000..65bea7e270 --- /dev/null +++ b/test/language/module-code/top-level-await/new-await-script-code.js @@ -0,0 +1,13 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-AwaitExpression +description: > + await is not a keyword in script code +features: [top-level-await] +---*/ + +class await {} + +assert.sameValue(new await instanceof await, true); diff --git a/test/language/module-code/top-level-await/new-await.js b/test/language/module-code/top-level-await/new-await.js new file mode 100644 index 0000000000..ad8d9507ae --- /dev/null +++ b/test/language/module-code/top-level-await/new-await.js @@ -0,0 +1,17 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-AwaitExpression +description: > + await cannot immediately follow new in module code +negative: + phase: parse + type: SyntaxError +flags: [module] +features: [top-level-await] +---*/ + +$DONOTEVALUATE(); + +new await;