Add tests for async generator function expressions

This commit is contained in:
Caitlin Potter 2017-01-11 17:29:03 -05:00 committed by Rick Waldron
parent 82c2ca0709
commit 6391689a6b
28 changed files with 512 additions and 0 deletions

View File

@ -0,0 +1,15 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
author: Caitlin Potter <caitp@igalia.com>
esid: pending
description: >
It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and
IsSimpleParameterList of UniqueFormalParameters is false.
negative:
phase: early
type: SyntaxError
---*/
(async function*(x = 1) {"use strict"});

View File

@ -0,0 +1,15 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
author: Caitlin Potter <caitp@igalia.com>
esid: pending
description: >
It is a SyntaxError if FormalParameters contains arguments in strict mode.
negative:
phase: early
type: SyntaxError
flags: [onlyStrict]
---*/
(async function*(arguments) { });

View File

@ -0,0 +1,14 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
author: Caitlin Potter <caitp@igalia.com>
esid: 12.1.1
description: >
`await` is not a valid BindingIdentifier for AsyncGeneratorExpressions.
negative:
phase: early
type: SyntaxError
---*/
(async function* await() { });

View File

@ -0,0 +1,16 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
author: Caitlin Potter <caitp@igalia.com>
esid: pending
description: >
If the source code matching this production is strict code, it is a
Syntax Error if BindingIdentifier is the IdentifierName arguments.
negative:
phase: early
type: SyntaxError
flags: [onlyStrict]
---*/
(async function* arguments() { });

View File

@ -0,0 +1,16 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
author: Caitlin Potter <caitp@igalia.com>
esid: pending
description: >
If the source code matching this production is strict code, it is a
Syntax Error if BindingIdentifier is the IdentifierName eval.
negative:
phase: early
type: SyntaxError
flags: [onlyStrict]
---*/
(async function* eval() { });

View File

@ -0,0 +1,14 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
author: Caitlin Potter <caitp@igalia.com>
esid: pending
description: >
It is a syntax error if AsyncGeneratorBody contains SuperCall is true.
negative:
phase: early
type: SyntaxError
---*/
(async function*() { super(); });

View File

@ -0,0 +1,14 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
author: Caitlin Potter <caitp@igalia.com>
esid: pending
description: >
It is a syntax error if AsyncGeneratorBody contains SuperProperty is true.
negative:
phase: early
type: SyntaxError
---*/
(async function*() { super.prop; });

View File

@ -0,0 +1,15 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
author: Caitlin Potter <caitp@igalia.com>
esid: pending
description: >
It is a SyntaxError if FormalParameters contains eval in strict mode.
negative:
phase: early
type: SyntaxError
flags: [onlyStrict]
---*/
(async function*(eval) { });

View File

@ -0,0 +1,15 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
author: Caitlin Potter <caitp@igalia.com>
esid: pending
description: >
It is a SyntaxError if BoundNames of FormalParameters also occurs in the
LexicallyDeclaredNames of AsyncFunctionBody
negative:
phase: early
type: SyntaxError
---*/
(async function*(a) { const a = 0; });

View File

@ -0,0 +1,15 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
author: Caitlin Potter <caitp@igalia.com>
esid: pending
description: >
It is a SyntaxError if BoundNames of FormalParameters also occurs in the
LexicallyDeclaredNames of AsyncFunctionBody
negative:
phase: early
type: SyntaxError
---*/
(async function*(a) { let a; });

View File

@ -0,0 +1,14 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
author: Caitlin Potter <caitp@igalia.com>
esid: pending
description: >
It is a Syntax Error if FormalParameters Contains AwaitExpression is true.
negative:
phase: early
type: SyntaxError
---*/
(async function*(x = await 1) { });

View File

@ -0,0 +1,15 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
author: Caitlin Potter <caitp@igalia.com>
esid: 12.1
description: >
`await` is a reserved keyword within async generator function bodies and may
not be used as the binding identifier of a parameter.
negative:
phase: early
type: SyntaxError
---*/
(async function*(await) { });

View File

@ -0,0 +1,14 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
author: Caitlin Potter <caitp@igalia.com>
esid: pending
description: >
It is a syntax error if FormalParameters contains SuperCall is true.
negative:
phase: early
type: SyntaxError
---*/
(async function*(a = super()) { });

View File

@ -0,0 +1,14 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
author: Caitlin Potter <caitp@igalia.com>
esid: pending
description: >
It is a syntax error if FormalParameters contains SuperProperty is true.
negative:
phase: early
type: SyntaxError
---*/
(async function*(a = super.prop) { });

View File

@ -0,0 +1,14 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
author: Caitlin Potter <caitp@igalia.com>
esid: pending
description: >
It is a Syntax Error if FormalParameters Contains YieldExpression is true.
negative:
phase: early
type: SyntaxError
---*/
(async function*(x = yield) { });

View File

@ -0,0 +1,15 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
author: Caitlin Potter <caitp@igalia.com>
esid: 12.1
description: >
`await` is a reserved keyword within async generator function bodies and may
not be used as the binding identifier of a parameter.
negative:
phase: early
type: SyntaxError
---*/
(async function*(yield) { });

View File

@ -0,0 +1,17 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
author: Caitlin Potter <caitp@igalia.com>
esid: 12.1.1
description: >
`await` is a reserved keyword within async generator function bodies and may
not be used as a label.
negative:
phase: early
type: SyntaxError
---*/
(async function*() {
await: 1;
});

View File

@ -0,0 +1,17 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
author: Caitlin Potter <caitp@igalia.com>
esid: 12.1.1
description: >
`yield` is a reserved keyword within async generator function bodies and may
not be used as a label.
negative:
phase: early
type: SyntaxError
---*/
(async function*() {
yield: 1;
});

View File

@ -0,0 +1,14 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
author: Caitlin Potter <caitp@igalia.com>
esid: pending
description: >
Async generator function expressions are not a simple assignment target.
negative:
phase: early
type: ReferenceError
---*/
(async function*() { } = 1);

View File

@ -0,0 +1,14 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
author: Caitlin Potter <caitp@igalia.com>
esid: 12.1.1
description: >
`yield` is not a valid BindingIdentifier for AsyncGeneratorExpressions.
negative:
phase: early
type: SyntaxError
---*/
(async function* yield() { });

View File

@ -0,0 +1,17 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
author: Caitlin Potter <caitp@igalia.com>
esid: 14.4
description: >
A newline may not precede the `*` token in a `yield` expression.
negative:
phase: early
type: SyntaxError
---*/
(async function*() {
yield
* 1;
});

View File

@ -0,0 +1,24 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
author: Caitlin Potter <caitp@igalia.com>
esid: 14.4
description: >
AwaitExpressions are valid operands to yield expressions.
flags: [async]
---*/
var iter = (async function*() {
yield await "a";
})();
iter.next().then(function(result) {
assert.sameValue(result.value, "a", 'First result `value`');
assert.sameValue(result.done, false, 'First result `done` flag');
}).then(undefined, $DONE);
iter.next().then(function(result) {
assert.sameValue(result.value, undefined, 'Second result `value`');
assert.sameValue(result.done, true, 'Second result `done` flag');
}).then($DONE, $DONE);

View File

@ -0,0 +1,26 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
author: Caitlin Potter <caitp@igalia.com>
esid: 14.4
description: >
AwaitExpressions are valid operands to yield expressions.
flags: [async]
---*/
var iter = (async function*() {
yield await new Promise(function(resolve) {
resolve("a");
});
})();
iter.next().then(function(result) {
assert.sameValue(result.value, "a", 'First result `value`');
assert.sameValue(result.done, false, 'First result `done` flag');
}).then(undefined, $DONE);
iter.next().then(function(result) {
assert.sameValue(result.value, undefined, 'Second result `value`');
assert.sameValue(result.done, true, 'Second result `done` flag');
}).then($DONE, $DONE);

View File

@ -0,0 +1,30 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
author: Caitlin Potter <caitp@igalia.com>
esid: 14.4
description: >
AwaitExpressions are valid operands to yield expressions.
flags: [async]
---*/
var thenable = {
then: function(resolve, reject) {
resolve("a");
}
};
var iter = (async function*() {
yield await thenable;
})();
iter.next().then(function(result) {
assert.sameValue(result.value, "a", 'First result `value`');
assert.sameValue(result.done, false, 'First result `done` flag');
}).then(undefined, $DONE);
iter.next().then(function(result) {
assert.sameValue(result.value, undefined, 'Second result `value`');
assert.sameValue(result.done, true, 'Second result `done` flag');
}).then($DONE, $DONE);

View File

@ -0,0 +1,31 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
author: Caitlin Potter <caitp@igalia.com>
esid: 14.4
description: >
`yield` expressions may be used as the right-hand-side of other `yield`
expressions.
flags: [async]
---*/
var g = async function*() {
yield yield 1;
};
var iter = g();
iter.next().then(function(result) {
assert.sameValue(result.value, 1, 'First result `value`');
assert.sameValue(result.done, false, 'First result `done` flag');
}).then(undefined, $DONE);
iter.next().then(function(result) {
assert.sameValue(result.value, undefined, 'Second result `value`');
assert.sameValue(result.done, false, 'Second result `done` flag');
}).then(undefined, $DONE);
iter.next().then(function(result) {
assert.sameValue(result.value, undefined, 'Third result `value`');
assert.sameValue(result.done, true, 'Thid result `done` flag');
}).then($DONE, $DONE);

View File

@ -0,0 +1,41 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
author: Caitlin Potter <caitp@igalia.com>
esid: 14.4
description: >
`yield` is a valid statement within async generator function bodies.
flags: [async]
---*/
var g1 = async function*() { yield; };
var g2 = async function*() { yield 1; };
var iter1 = g1();
iter1.next().then(function(result) {
assert.sameValue(
result.value, undefined, "Without right-hand-side: first result `value`");
assert.sameValue(
result.done, false, "Without right-hand-side: first result `done` flag");
}).then(undefined, $DONE);
iter1.next(function(result) {
assert.sameValue(
result.value, undefined, "Without right-hand-side: second result `value`");
assert.sameValue(
result.done, true, "Without right-hand-side: second result `done` flag");
}).then(undefined, $DONE);
var iter2 = g2();
iter2.next().then(function(result) {
assert.sameValue(
result.value, 1, "With right-hand-side: first result `value`");
assert.sameValue(
result.done, false, "With right-hand-side: first result `done` flag");
}).then(undefined, $DONE);
iter2.next(function(result) {
assert.sameValue(
result.value, undefined, "With right-hand-side: second result `value`");
assert.sameValue(
result.done, true, "With right-hand-side: second result `done` flag");
}).then($DONE, $DONE);

View File

@ -0,0 +1,26 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
author: Caitlin Potter <caitp@igalia.com>
esid: 14.4
description: >
Newlines terminate `yield` expressions.
flags: [async]
---*/
var g = async function*() {
yield
1;
};
var iter = g();
iter.next().then(function(result) {
assert.sameValue(result.value, undefined, 'First result `value`');
assert.sameValue(result.done, false, 'First result `done` flag');
}).then(undefined, $DONE);
iter.next().then(function(result) {
assert.sameValue(result.value, undefined, 'Second result `value`');
assert.sameValue(result.done, true, 'Second result `done` flag');
}).then($DONE, $DONE);

View File

@ -0,0 +1,20 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
author: Caitlin Potter <caitp@igalia.com>
esid: 14.4
description: >
The right-hand side of a `yield *` expression may appear on a new line.
flags: [async]
---*/
var g = async function*() {};
(async function*() {
yield*
g();
})().next().then(function(result) {
assert.sameValue(result.value, undefined);
assert.sameValue(result.done, true);
}).then($DONE, $DONE);