Add tests for use of `yield` in default parameters

This commit is contained in:
Mike Pennisi 2016-06-02 11:18:06 -04:00 committed by Leonardo Balter
parent e5f1740411
commit 7dcccfcca6
No known key found for this signature in database
GPG Key ID: 3151533059133F60
17 changed files with 369 additions and 0 deletions

View File

@ -0,0 +1,24 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-arrow-function-definitions
es6id: 14.2
description: >
The `yield` token is interpreted contextually outside of strict mode
info: |
ArrowFunction[In, Yield] :
ArrowParameters[?Yield] [no LineTerminator here] => ConciseBody[?In]
14.2.1 Static Semantics: Early Errors#
ArrowFunction : ArrowParameters=>ConciseBody
- It is a Syntax Error if ArrowParameters Contains YieldExpression is true.
features: [generators, default-parameters]
negative: SyntaxError
---*/
function *g() {
(x = yield) => {};
}

View File

@ -0,0 +1,25 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-arrow-function-definitions
es6id: 14.2
description: >
The `yield` token is interpreted as an IdentifierReference outside of strict
mode and outside of generator function bodies.
info: |
ArrowFunction[In, Yield] :
ArrowParameters[?Yield] [no LineTerminator here] => ConciseBody[?In]
features: [default-parameters]
flags: [onlyStrict]
negative: SyntaxError
---*/
var yield = 23;
var f, paramValue;
f = (x = yield) => { paramValue = x; };
f();
assert.sameValue(paramValue, 23);

View File

@ -0,0 +1,17 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-arrow-function-definitions
es6id: 14.2
description: >
The `yield` token is interpreted as a FutureReservedWord within strict mode
info: |
ArrowFunction[In, Yield] :
ArrowParameters[?Yield] [no LineTerminator here] => ConciseBody[?In]
features: [default-parameters]
flags: [onlyStrict]
negative: SyntaxError
---*/
(x = yield) => {};

View File

@ -0,0 +1,23 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-generator-function-definitions
es6id: 14.4
description: >
YieldExpression cannot be used within the FormalParameters of a generator
function
info: |
GeneratorMethod[Yield]:
* PropertyName[?Yield] ( StrictFormalParameters[Yield] ) { GeneratorBody }
YieldExpression cannot be used within the FormalParameters of a generator
function because any expressions that are part of FormalParameters are
evaluated before the resulting generator object is in a resumable state.
features: [generators, default-parameters]
negative: SyntaxError
---*/
0, class {
*g(x = yield) {}
};

View File

@ -0,0 +1,18 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-method-definitions
es6id: 14.3
description: >
YieldExpression cannot be used within the FormalParameters of a class method
info: |
MethodDefinition[Yield] :
PropertyName[?Yield] ( StrictFormalParameters ) { FunctionBody }
features: [generators, default-parameters]
negative: SyntaxError
---*/
0, class {
m(x = yield) {}
};

View File

@ -0,0 +1,23 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-generator-function-definitions
es6id: 14.4
description: >
YieldExpression cannot be used within the FormalParameters of a generator
function
info: |
GeneratorMethod[Yield]:
* PropertyName[?Yield] ( StrictFormalParameters[Yield] ) { GeneratorBody }
YieldExpression cannot be used within the FormalParameters of a generator
function because any expressions that are part of FormalParameters are
evaluated before the resulting generator object is in a resumable state.
features: [generators, default-parameters]
negative: SyntaxError
---*/
0, class {
static *g(x = yield) {}
};

View File

@ -0,0 +1,18 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-method-definitions
es6id: 14.3
description: >
YieldExpression cannot be used within the FormalParameters of a class method
info: |
MethodDefinition[Yield] :
PropertyName[?Yield] ( StrictFormalParameters ) { FunctionBody }
features: [generators, default-parameters]
negative: SyntaxError
---*/
0, class {
static m(x = yield) {}
};

View File

@ -0,0 +1,27 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-function-definitions
es6id: 14.1
description: >
The `yield` token is interpreted as an IdentifierReference within a generator
and outside of strict mode
info: |
FunctionExpression :
function BindingIdentifieropt ( FormalParameters ) { FunctionBody }
features: [generators, default-parameters]
flags: [noStrict]
---*/
var yield = 23;
var paramValue;
function *g() {
(function(x = yield) {
paramValue = x;
}());
}
g().next();
assert.sameValue(paramValue, 23);

View File

@ -0,0 +1,21 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-function-definitions
es6id: 14.1
description: >
The `yield` token is interpreted as an IdentifierReference within a generator
and outside of strict mode
info: |
FunctionExpression :
function BindingIdentifieropt ( FormalParameters ) { FunctionBody }
features: [generators, default-parameters]
flags: [onlyStrict]
negative: SyntaxError
---*/
function *g() {
0, function(x = yield) {
paramValue = x;
};
}

View File

@ -0,0 +1,21 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-generator-function-definitions
es6id: 14.4
description: >
YieldExpression cannot be used within the FormalParameters of a generator
function
info: |
GeneratorExpression :
function * BindingIdentifier[Yield]opt ( FormalParameters[Yield] ) { GeneratorBody }
YieldExpression cannot be used within the FormalParameters of a generator
function because any expressions that are part of FormalParameters are
evaluated before the resulting generator object is in a resumable state.
features: [default-parameters]
negative: SyntaxError
---*/
0, function*(x = yield) {};

View File

@ -0,0 +1,23 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-generator-function-definitions
es6id: 14.4
description: >
YieldExpression cannot be used within the FormalParameters of a generator
function
info: |
GeneratorMethod[Yield]:
* PropertyName[?Yield] ( StrictFormalParameters[Yield] ) { GeneratorBody }
YieldExpression cannot be used within the FormalParameters of a generator
function because any expressions that are part of FormalParameters are
evaluated before the resulting generator object is in a resumable state.
features: [generators, default-parameters]
negative: SyntaxError
---*/
class C {
*g(x = yield) {}
}

View File

@ -0,0 +1,18 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-method-definitions
es6id: 14.3
description: >
YieldExpression cannot be used within the FormalParameters of a class method
info: |
MethodDefinition[Yield] :
PropertyName[?Yield] ( StrictFormalParameters ) { FunctionBody }
features: [generators, default-parameters]
negative: SyntaxError
---*/
class C {
m(x = yield) {}
}

View File

@ -0,0 +1,23 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-generator-function-definitions
es6id: 14.4
description: >
YieldExpression cannot be used within the FormalParameters of a generator
function
info: |
GeneratorMethod[Yield]:
* PropertyName[?Yield] ( StrictFormalParameters[Yield] ) { GeneratorBody }
YieldExpression cannot be used within the FormalParameters of a generator
function because any expressions that are part of FormalParameters are
evaluated before the resulting generator object is in a resumable state.
features: [generators, default-parameters]
negative: SyntaxError
---*/
class C {
static *g(x = yield) {}
}

View File

@ -0,0 +1,18 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-method-definitions
es6id: 14.3
description: >
YieldExpression cannot be used within the FormalParameters of a class method
info: |
MethodDefinition[Yield] :
PropertyName[?Yield] ( StrictFormalParameters ) { FunctionBody }
features: [generators, default-parameters]
negative: SyntaxError
---*/
class C {
static m(x = yield) {}
}

View File

@ -0,0 +1,29 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-function-definitions
es6id: 14.1
description: >
The `yield` token is interpreted as an IdentifierReference within a generator
and outside of strict mode
info: |
FunctionDeclaration[Yield, Default] :
function BindingIdentifier[?Yield] ( FormalParameters ) { FunctionBody }
features: [generators, default-parameters]
flags: [noStrict]
---*/
var yield = 23;
var paramValue;
function *g() {
function f(x = yield) {
paramValue = x;
}
f();
}
g().next();
assert.sameValue(paramValue, 23);

View File

@ -0,0 +1,21 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-function-definitions
es6id: 14.1
description: >
The `yield` token is interpreted as an IdentifierReference within a generator
and outside of strict mode
info: |
FunctionDeclaration[Yield, Default] :
function BindingIdentifier[?Yield] ( FormalParameters ) { FunctionBody }
features: [generators, default-parameters]
flags: [onlyStrict]
negative: SyntaxError
---*/
function *g() {
function f(x = yield) {
paramValue = x;
}
}

View File

@ -0,0 +1,20 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-generator-function-definitions
es6id: 14.4
description: >
YieldExpression cannot be used within the FormalParameters of a generator
function
info: |
GeneratorDeclaration[Yield, Default] :
function * BindingIdentifier[?Yield] ( FormalParameters[Yield] ) { GeneratorBody }
YieldExpression cannot be used within the FormalParameters of a generator
function because any expressions that are part of FormalParameters are
evaluated before the resulting generator object is in a resumable state.
features: [default-parameters]
negative: SyntaxError
---*/
function* g(x = yield) {}