Coverage: `new await ...` and `new (await ...)`. Fixes gh-1898

This commit is contained in:
Rick Waldron 2020-08-21 16:26:53 -04:00
parent 6397602037
commit 758b9ec575
3 changed files with 49 additions and 0 deletions

View File

@ -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();

View File

@ -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);

View File

@ -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;