mirror of
https://github.com/tc39/test262.git
synced 2025-07-30 09:24:41 +02:00
Add tests for use of yield
in default parameters
This commit is contained in:
parent
e5f1740411
commit
7dcccfcca6
@ -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) => {};
|
||||||
|
}
|
@ -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);
|
@ -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) => {};
|
@ -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) {}
|
||||||
|
};
|
18
test/language/expressions/class/method-param-dflt-yield.js
Normal file
18
test/language/expressions/class/method-param-dflt-yield.js
Normal 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) {}
|
||||||
|
};
|
@ -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) {}
|
||||||
|
};
|
@ -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) {}
|
||||||
|
};
|
@ -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);
|
@ -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;
|
||||||
|
};
|
||||||
|
}
|
21
test/language/expressions/generators/param-dflt-yield.js
Normal file
21
test/language/expressions/generators/param-dflt-yield.js
Normal 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) {};
|
@ -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) {}
|
||||||
|
}
|
18
test/language/statements/class/method-param-yield.js
Normal file
18
test/language/statements/class/method-param-yield.js
Normal 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) {}
|
||||||
|
}
|
@ -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) {}
|
||||||
|
}
|
18
test/language/statements/class/static-method-param-yield.js
Normal file
18
test/language/statements/class/static-method-param-yield.js
Normal 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) {}
|
||||||
|
}
|
@ -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);
|
21
test/language/statements/function/param-dflt-yield-strict.js
Normal file
21
test/language/statements/function/param-dflt-yield-strict.js
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
20
test/language/statements/generators/param-dflt-yield.js
Normal file
20
test/language/statements/generators/param-dflt-yield.js
Normal 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) {}
|
Loading…
x
Reference in New Issue
Block a user