mirror of https://github.com/tc39/test262.git
Generate tests
This commit is contained in:
parent
77fbf1cada
commit
e54c471809
|
@ -0,0 +1,50 @@
|
||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/generators/yield-identifier-spread-strict.case
|
||||||
|
// - src/generators/default/class-method-definition.template
|
||||||
|
/*---
|
||||||
|
description: It's an early error if the AssignmentExpression is a function body with yield as an identifier in strict mode. (Generator method as a ClassElement)
|
||||||
|
esid: prod-GeneratorMethod
|
||||||
|
features: [object-spread]
|
||||||
|
flags: [generated, onlyStrict]
|
||||||
|
negative:
|
||||||
|
phase: early
|
||||||
|
type: SyntaxError
|
||||||
|
info: |
|
||||||
|
ClassElement[Yield, Await]:
|
||||||
|
MethodDefinition[?Yield, ?Await]
|
||||||
|
|
||||||
|
MethodDefinition[Yield, Await]:
|
||||||
|
GeneratorMethod[?Yield, ?Await]
|
||||||
|
|
||||||
|
14.4 Generator Function Definitions
|
||||||
|
|
||||||
|
GeneratorMethod[Yield, Await]:
|
||||||
|
* PropertyName[?Yield, ?Await] ( UniqueFormalParameters[+Yield, ~Await] ) { GeneratorBody }
|
||||||
|
|
||||||
|
Spread Properties
|
||||||
|
|
||||||
|
PropertyDefinition[Yield]:
|
||||||
|
(...)
|
||||||
|
...AssignmentExpression[In, ?Yield]
|
||||||
|
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var callCount = 0;
|
||||||
|
|
||||||
|
class C { *gen() {
|
||||||
|
callCount += 1;
|
||||||
|
return {
|
||||||
|
...(function() {
|
||||||
|
var yield;
|
||||||
|
throw new Test262Error();
|
||||||
|
}()),
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
|
||||||
|
var gen = C.prototype.gen;
|
||||||
|
|
||||||
|
var iter = gen();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
assert.sameValue(callCount, 1);
|
|
@ -0,0 +1,40 @@
|
||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/generators/yield-identifier-strict.case
|
||||||
|
// - src/generators/default/class-method-definition.template
|
||||||
|
/*---
|
||||||
|
description: It's an early error if the generator body has another function body with yield as an identifier in strict mode. (Generator method as a ClassElement)
|
||||||
|
esid: prod-GeneratorMethod
|
||||||
|
flags: [generated, onlyStrict]
|
||||||
|
negative:
|
||||||
|
phase: early
|
||||||
|
type: SyntaxError
|
||||||
|
info: |
|
||||||
|
ClassElement[Yield, Await]:
|
||||||
|
MethodDefinition[?Yield, ?Await]
|
||||||
|
|
||||||
|
MethodDefinition[Yield, Await]:
|
||||||
|
GeneratorMethod[?Yield, ?Await]
|
||||||
|
|
||||||
|
14.4 Generator Function Definitions
|
||||||
|
|
||||||
|
GeneratorMethod[Yield, Await]:
|
||||||
|
* PropertyName[?Yield, ?Await] ( UniqueFormalParameters[+Yield, ~Await] ) { GeneratorBody }
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var callCount = 0;
|
||||||
|
|
||||||
|
class C { *gen() {
|
||||||
|
callCount += 1;
|
||||||
|
(function() {
|
||||||
|
var yield;
|
||||||
|
throw new Test262Error();
|
||||||
|
}())
|
||||||
|
}}
|
||||||
|
|
||||||
|
var gen = C.prototype.gen;
|
||||||
|
|
||||||
|
var iter = gen();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
assert.sameValue(callCount, 1);
|
|
@ -0,0 +1,48 @@
|
||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/generators/yield-spread-arr-multiple.case
|
||||||
|
// - src/generators/default/class-method-definition.template
|
||||||
|
/*---
|
||||||
|
description: Use yield value in a array spread position (Generator method as a ClassElement)
|
||||||
|
esid: prod-GeneratorMethod
|
||||||
|
flags: [generated]
|
||||||
|
includes: [compareArray.js]
|
||||||
|
info: |
|
||||||
|
ClassElement[Yield, Await]:
|
||||||
|
MethodDefinition[?Yield, ?Await]
|
||||||
|
|
||||||
|
MethodDefinition[Yield, Await]:
|
||||||
|
GeneratorMethod[?Yield, ?Await]
|
||||||
|
|
||||||
|
14.4 Generator Function Definitions
|
||||||
|
|
||||||
|
GeneratorMethod[Yield, Await]:
|
||||||
|
* PropertyName[?Yield, ?Await] ( UniqueFormalParameters[+Yield, ~Await] ) { GeneratorBody }
|
||||||
|
|
||||||
|
Array Initializer
|
||||||
|
|
||||||
|
SpreadElement[Yield, Await]:
|
||||||
|
...AssignmentExpression[+In, ?Yield, ?Await]
|
||||||
|
|
||||||
|
---*/
|
||||||
|
var arr = ['a', 'b', 'c'];
|
||||||
|
var item;
|
||||||
|
|
||||||
|
var callCount = 0;
|
||||||
|
|
||||||
|
class C { *gen() {
|
||||||
|
callCount += 1;
|
||||||
|
yield [...yield yield];
|
||||||
|
}}
|
||||||
|
|
||||||
|
var gen = C.prototype.gen;
|
||||||
|
|
||||||
|
var iter = gen();
|
||||||
|
|
||||||
|
iter.next(false);
|
||||||
|
item = iter.next(['a', 'b', 'c']);
|
||||||
|
item = iter.next(item.value);
|
||||||
|
|
||||||
|
assert(compareArray(item.value, arr));
|
||||||
|
assert.sameValue(item.done, false);
|
||||||
|
|
||||||
|
assert.sameValue(callCount, 1);
|
|
@ -0,0 +1,46 @@
|
||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/generators/yield-spread-arr-single.case
|
||||||
|
// - src/generators/default/class-method-definition.template
|
||||||
|
/*---
|
||||||
|
description: Use yield value in a array spread position (Generator method as a ClassElement)
|
||||||
|
esid: prod-GeneratorMethod
|
||||||
|
flags: [generated]
|
||||||
|
includes: [compareArray.js]
|
||||||
|
info: |
|
||||||
|
ClassElement[Yield, Await]:
|
||||||
|
MethodDefinition[?Yield, ?Await]
|
||||||
|
|
||||||
|
MethodDefinition[Yield, Await]:
|
||||||
|
GeneratorMethod[?Yield, ?Await]
|
||||||
|
|
||||||
|
14.4 Generator Function Definitions
|
||||||
|
|
||||||
|
GeneratorMethod[Yield, Await]:
|
||||||
|
* PropertyName[?Yield, ?Await] ( UniqueFormalParameters[+Yield, ~Await] ) { GeneratorBody }
|
||||||
|
|
||||||
|
Array Initializer
|
||||||
|
|
||||||
|
SpreadElement[Yield, Await]:
|
||||||
|
...AssignmentExpression[+In, ?Yield, ?Await]
|
||||||
|
|
||||||
|
---*/
|
||||||
|
var arr = ['a', 'b', 'c'];
|
||||||
|
|
||||||
|
var callCount = 0;
|
||||||
|
|
||||||
|
class C { *gen() {
|
||||||
|
callCount += 1;
|
||||||
|
yield [...yield];
|
||||||
|
}}
|
||||||
|
|
||||||
|
var gen = C.prototype.gen;
|
||||||
|
|
||||||
|
var iter = gen();
|
||||||
|
|
||||||
|
iter.next(false);
|
||||||
|
var item = iter.next(['a', 'b', 'c']);
|
||||||
|
|
||||||
|
assert(compareArray(item.value, arr));
|
||||||
|
assert.sameValue(item.done, false);
|
||||||
|
|
||||||
|
assert.sameValue(callCount, 1);
|
|
@ -0,0 +1,55 @@
|
||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/generators/yield-spread-obj.case
|
||||||
|
// - src/generators/default/class-method-definition.template
|
||||||
|
/*---
|
||||||
|
description: Use yield value in a object spread position (Generator method as a ClassElement)
|
||||||
|
esid: prod-GeneratorMethod
|
||||||
|
features: [object-spread]
|
||||||
|
flags: [generated]
|
||||||
|
includes: [compareArray.js]
|
||||||
|
info: |
|
||||||
|
ClassElement[Yield, Await]:
|
||||||
|
MethodDefinition[?Yield, ?Await]
|
||||||
|
|
||||||
|
MethodDefinition[Yield, Await]:
|
||||||
|
GeneratorMethod[?Yield, ?Await]
|
||||||
|
|
||||||
|
14.4 Generator Function Definitions
|
||||||
|
|
||||||
|
GeneratorMethod[Yield, Await]:
|
||||||
|
* PropertyName[?Yield, ?Await] ( UniqueFormalParameters[+Yield, ~Await] ) { GeneratorBody }
|
||||||
|
|
||||||
|
Spread Properties
|
||||||
|
|
||||||
|
PropertyDefinition[Yield]:
|
||||||
|
(...)
|
||||||
|
...AssignmentExpression[In, ?Yield]
|
||||||
|
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var callCount = 0;
|
||||||
|
|
||||||
|
class C { *gen() {
|
||||||
|
callCount += 1;
|
||||||
|
yield {
|
||||||
|
...yield,
|
||||||
|
y: 1,
|
||||||
|
...yield yield,
|
||||||
|
};
|
||||||
|
}}
|
||||||
|
|
||||||
|
var gen = C.prototype.gen;
|
||||||
|
|
||||||
|
var iter = gen();
|
||||||
|
|
||||||
|
iter.next();
|
||||||
|
iter.next({ x: 42 });
|
||||||
|
iter.next({ x: 'lol' });
|
||||||
|
var item = iter.next({ y: 39 });
|
||||||
|
|
||||||
|
assert.sameValue(item.value.x, 42);
|
||||||
|
assert.sameValue(item.value.y, 39);
|
||||||
|
assert.sameValue(Object.keys(item.value).length, 2);
|
||||||
|
assert.sameValue(item.done, false);
|
||||||
|
|
||||||
|
assert.sameValue(callCount, 1);
|
|
@ -0,0 +1,37 @@
|
||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/generators/yield-identifier-non-strict.case
|
||||||
|
// - src/generators/non-strict/expression.template
|
||||||
|
/*---
|
||||||
|
description: Use of yield as a valid identifier in a function body inside a generator body in non strict mode (Generator expression - valid for non-strict only cases)
|
||||||
|
esid: prod-GeneratorExpression
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: |
|
||||||
|
14.4 Generator Function Definitions
|
||||||
|
|
||||||
|
GeneratorExpression:
|
||||||
|
function * BindingIdentifier[+Yield, ~Await]opt ( FormalParameters[+Yield, ~Await] ) { GeneratorBody }
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var callCount = 0;
|
||||||
|
|
||||||
|
var gen = function *() {
|
||||||
|
callCount += 1;
|
||||||
|
return (function(arg) {
|
||||||
|
var yield = arg + 1;
|
||||||
|
return yield;
|
||||||
|
}(yield))
|
||||||
|
};
|
||||||
|
|
||||||
|
var iter = gen();
|
||||||
|
|
||||||
|
var item = iter.next();
|
||||||
|
|
||||||
|
assert.sameValue(item.done, false);
|
||||||
|
assert.sameValue(item.value, undefined);
|
||||||
|
|
||||||
|
item = iter.next(42);
|
||||||
|
|
||||||
|
assert.sameValue(item.done, true);
|
||||||
|
assert.sameValue(item.value, 43);
|
||||||
|
|
||||||
|
assert.sameValue(callCount, 1);
|
|
@ -0,0 +1,55 @@
|
||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/generators/yield-identifier-spread-non-strict.case
|
||||||
|
// - src/generators/non-strict/expression.template
|
||||||
|
/*---
|
||||||
|
description: Mixed use of object spread and yield as a valid identifier in a function body inside a generator body in non strict mode (Generator expression - valid for non-strict only cases)
|
||||||
|
esid: prod-GeneratorExpression
|
||||||
|
features: [object-spread]
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: |
|
||||||
|
14.4 Generator Function Definitions
|
||||||
|
|
||||||
|
GeneratorExpression:
|
||||||
|
function * BindingIdentifier[+Yield, ~Await]opt ( FormalParameters[+Yield, ~Await] ) { GeneratorBody }
|
||||||
|
|
||||||
|
Spread Properties
|
||||||
|
|
||||||
|
PropertyDefinition[Yield]:
|
||||||
|
(...)
|
||||||
|
...AssignmentExpression[In, ?Yield]
|
||||||
|
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var callCount = 0;
|
||||||
|
|
||||||
|
var gen = function *() {
|
||||||
|
callCount += 1;
|
||||||
|
yield {
|
||||||
|
...yield yield,
|
||||||
|
...(function(arg) {
|
||||||
|
var yield = arg;
|
||||||
|
return {...yield};
|
||||||
|
}(yield)),
|
||||||
|
...yield,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var iter = gen();
|
||||||
|
|
||||||
|
var iter = gen();
|
||||||
|
|
||||||
|
iter.next();
|
||||||
|
iter.next();
|
||||||
|
iter.next({ x: 10, a: 0, b: 0 });
|
||||||
|
iter.next({ y: 20, a: 1, b: 1 });
|
||||||
|
var item = iter.next({ z: 30, b: 2 });
|
||||||
|
|
||||||
|
assert.sameValue(item.done, false);
|
||||||
|
assert.sameValue(item.value.x, 10);
|
||||||
|
assert.sameValue(item.value.y, 20);
|
||||||
|
assert.sameValue(item.value.z, 30);
|
||||||
|
assert.sameValue(item.value.a, 1);
|
||||||
|
assert.sameValue(item.value.b, 2);
|
||||||
|
assert.sameValue(Object.keys(item.value).length, 5);
|
||||||
|
|
||||||
|
assert.sameValue(callCount, 1);
|
|
@ -0,0 +1,42 @@
|
||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/generators/yield-identifier-spread-strict.case
|
||||||
|
// - src/generators/default/expression.template
|
||||||
|
/*---
|
||||||
|
description: It's an early error if the AssignmentExpression is a function body with yield as an identifier in strict mode. (Generator expression)
|
||||||
|
esid: prod-GeneratorExpression
|
||||||
|
features: [object-spread]
|
||||||
|
flags: [generated, onlyStrict]
|
||||||
|
negative:
|
||||||
|
phase: early
|
||||||
|
type: SyntaxError
|
||||||
|
info: |
|
||||||
|
14.4 Generator Function Definitions
|
||||||
|
|
||||||
|
GeneratorExpression:
|
||||||
|
function * BindingIdentifier[+Yield, ~Await]opt ( FormalParameters[+Yield, ~Await] ) { GeneratorBody }
|
||||||
|
|
||||||
|
Spread Properties
|
||||||
|
|
||||||
|
PropertyDefinition[Yield]:
|
||||||
|
(...)
|
||||||
|
...AssignmentExpression[In, ?Yield]
|
||||||
|
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var callCount = 0;
|
||||||
|
|
||||||
|
var gen = function *() {
|
||||||
|
callCount += 1;
|
||||||
|
return {
|
||||||
|
...(function() {
|
||||||
|
var yield;
|
||||||
|
throw new Test262Error();
|
||||||
|
}()),
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var iter = gen();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
assert.sameValue(callCount, 1);
|
|
@ -0,0 +1,32 @@
|
||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/generators/yield-identifier-strict.case
|
||||||
|
// - src/generators/default/expression.template
|
||||||
|
/*---
|
||||||
|
description: It's an early error if the generator body has another function body with yield as an identifier in strict mode. (Generator expression)
|
||||||
|
esid: prod-GeneratorExpression
|
||||||
|
flags: [generated, onlyStrict]
|
||||||
|
negative:
|
||||||
|
phase: early
|
||||||
|
type: SyntaxError
|
||||||
|
info: |
|
||||||
|
14.4 Generator Function Definitions
|
||||||
|
|
||||||
|
GeneratorExpression:
|
||||||
|
function * BindingIdentifier[+Yield, ~Await]opt ( FormalParameters[+Yield, ~Await] ) { GeneratorBody }
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var callCount = 0;
|
||||||
|
|
||||||
|
var gen = function *() {
|
||||||
|
callCount += 1;
|
||||||
|
(function() {
|
||||||
|
var yield;
|
||||||
|
throw new Test262Error();
|
||||||
|
}())
|
||||||
|
};
|
||||||
|
|
||||||
|
var iter = gen();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
assert.sameValue(callCount, 1);
|
|
@ -0,0 +1,40 @@
|
||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/generators/yield-spread-arr-multiple.case
|
||||||
|
// - src/generators/default/expression.template
|
||||||
|
/*---
|
||||||
|
description: Use yield value in a array spread position (Generator expression)
|
||||||
|
esid: prod-GeneratorExpression
|
||||||
|
flags: [generated]
|
||||||
|
includes: [compareArray.js]
|
||||||
|
info: |
|
||||||
|
14.4 Generator Function Definitions
|
||||||
|
|
||||||
|
GeneratorExpression:
|
||||||
|
function * BindingIdentifier[+Yield, ~Await]opt ( FormalParameters[+Yield, ~Await] ) { GeneratorBody }
|
||||||
|
|
||||||
|
Array Initializer
|
||||||
|
|
||||||
|
SpreadElement[Yield, Await]:
|
||||||
|
...AssignmentExpression[+In, ?Yield, ?Await]
|
||||||
|
|
||||||
|
---*/
|
||||||
|
var arr = ['a', 'b', 'c'];
|
||||||
|
var item;
|
||||||
|
|
||||||
|
var callCount = 0;
|
||||||
|
|
||||||
|
var gen = function *() {
|
||||||
|
callCount += 1;
|
||||||
|
yield [...yield yield];
|
||||||
|
};
|
||||||
|
|
||||||
|
var iter = gen();
|
||||||
|
|
||||||
|
iter.next(false);
|
||||||
|
item = iter.next(['a', 'b', 'c']);
|
||||||
|
item = iter.next(item.value);
|
||||||
|
|
||||||
|
assert(compareArray(item.value, arr));
|
||||||
|
assert.sameValue(item.done, false);
|
||||||
|
|
||||||
|
assert.sameValue(callCount, 1);
|
|
@ -0,0 +1,38 @@
|
||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/generators/yield-spread-arr-single.case
|
||||||
|
// - src/generators/default/expression.template
|
||||||
|
/*---
|
||||||
|
description: Use yield value in a array spread position (Generator expression)
|
||||||
|
esid: prod-GeneratorExpression
|
||||||
|
flags: [generated]
|
||||||
|
includes: [compareArray.js]
|
||||||
|
info: |
|
||||||
|
14.4 Generator Function Definitions
|
||||||
|
|
||||||
|
GeneratorExpression:
|
||||||
|
function * BindingIdentifier[+Yield, ~Await]opt ( FormalParameters[+Yield, ~Await] ) { GeneratorBody }
|
||||||
|
|
||||||
|
Array Initializer
|
||||||
|
|
||||||
|
SpreadElement[Yield, Await]:
|
||||||
|
...AssignmentExpression[+In, ?Yield, ?Await]
|
||||||
|
|
||||||
|
---*/
|
||||||
|
var arr = ['a', 'b', 'c'];
|
||||||
|
|
||||||
|
var callCount = 0;
|
||||||
|
|
||||||
|
var gen = function *() {
|
||||||
|
callCount += 1;
|
||||||
|
yield [...yield];
|
||||||
|
};
|
||||||
|
|
||||||
|
var iter = gen();
|
||||||
|
|
||||||
|
iter.next(false);
|
||||||
|
var item = iter.next(['a', 'b', 'c']);
|
||||||
|
|
||||||
|
assert(compareArray(item.value, arr));
|
||||||
|
assert.sameValue(item.done, false);
|
||||||
|
|
||||||
|
assert.sameValue(callCount, 1);
|
|
@ -0,0 +1,47 @@
|
||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/generators/yield-spread-obj.case
|
||||||
|
// - src/generators/default/expression.template
|
||||||
|
/*---
|
||||||
|
description: Use yield value in a object spread position (Generator expression)
|
||||||
|
esid: prod-GeneratorExpression
|
||||||
|
features: [object-spread]
|
||||||
|
flags: [generated]
|
||||||
|
includes: [compareArray.js]
|
||||||
|
info: |
|
||||||
|
14.4 Generator Function Definitions
|
||||||
|
|
||||||
|
GeneratorExpression:
|
||||||
|
function * BindingIdentifier[+Yield, ~Await]opt ( FormalParameters[+Yield, ~Await] ) { GeneratorBody }
|
||||||
|
|
||||||
|
Spread Properties
|
||||||
|
|
||||||
|
PropertyDefinition[Yield]:
|
||||||
|
(...)
|
||||||
|
...AssignmentExpression[In, ?Yield]
|
||||||
|
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var callCount = 0;
|
||||||
|
|
||||||
|
var gen = function *() {
|
||||||
|
callCount += 1;
|
||||||
|
yield {
|
||||||
|
...yield,
|
||||||
|
y: 1,
|
||||||
|
...yield yield,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
var iter = gen();
|
||||||
|
|
||||||
|
iter.next();
|
||||||
|
iter.next({ x: 42 });
|
||||||
|
iter.next({ x: 'lol' });
|
||||||
|
var item = iter.next({ y: 39 });
|
||||||
|
|
||||||
|
assert.sameValue(item.value.x, 42);
|
||||||
|
assert.sameValue(item.value.y, 39);
|
||||||
|
assert.sameValue(Object.keys(item.value).length, 2);
|
||||||
|
assert.sameValue(item.done, false);
|
||||||
|
|
||||||
|
assert.sameValue(callCount, 1);
|
|
@ -0,0 +1,39 @@
|
||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/generators/yield-identifier-non-strict.case
|
||||||
|
// - src/generators/non-strict/method-definition.template
|
||||||
|
/*---
|
||||||
|
description: Use of yield as a valid identifier in a function body inside a generator body in non strict mode (Generator method - valid for non-strict only cases)
|
||||||
|
esid: prod-GeneratorMethod
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: |
|
||||||
|
14.4 Generator Function Definitions
|
||||||
|
|
||||||
|
GeneratorMethod[Yield, Await]:
|
||||||
|
* PropertyName[?Yield, ?Await] ( UniqueFormalParameters[+Yield, ~Await] ) { GeneratorBody }
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var callCount = 0;
|
||||||
|
|
||||||
|
var gen = {
|
||||||
|
*method() {
|
||||||
|
callCount += 1;
|
||||||
|
return (function(arg) {
|
||||||
|
var yield = arg + 1;
|
||||||
|
return yield;
|
||||||
|
}(yield))
|
||||||
|
}
|
||||||
|
}.method;
|
||||||
|
|
||||||
|
var iter = gen();
|
||||||
|
|
||||||
|
var item = iter.next();
|
||||||
|
|
||||||
|
assert.sameValue(item.done, false);
|
||||||
|
assert.sameValue(item.value, undefined);
|
||||||
|
|
||||||
|
item = iter.next(42);
|
||||||
|
|
||||||
|
assert.sameValue(item.done, true);
|
||||||
|
assert.sameValue(item.value, 43);
|
||||||
|
|
||||||
|
assert.sameValue(callCount, 1);
|
|
@ -0,0 +1,57 @@
|
||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/generators/yield-identifier-spread-non-strict.case
|
||||||
|
// - src/generators/non-strict/method-definition.template
|
||||||
|
/*---
|
||||||
|
description: Mixed use of object spread and yield as a valid identifier in a function body inside a generator body in non strict mode (Generator method - valid for non-strict only cases)
|
||||||
|
esid: prod-GeneratorMethod
|
||||||
|
features: [object-spread]
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: |
|
||||||
|
14.4 Generator Function Definitions
|
||||||
|
|
||||||
|
GeneratorMethod[Yield, Await]:
|
||||||
|
* PropertyName[?Yield, ?Await] ( UniqueFormalParameters[+Yield, ~Await] ) { GeneratorBody }
|
||||||
|
|
||||||
|
Spread Properties
|
||||||
|
|
||||||
|
PropertyDefinition[Yield]:
|
||||||
|
(...)
|
||||||
|
...AssignmentExpression[In, ?Yield]
|
||||||
|
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var callCount = 0;
|
||||||
|
|
||||||
|
var gen = {
|
||||||
|
*method() {
|
||||||
|
callCount += 1;
|
||||||
|
yield {
|
||||||
|
...yield yield,
|
||||||
|
...(function(arg) {
|
||||||
|
var yield = arg;
|
||||||
|
return {...yield};
|
||||||
|
}(yield)),
|
||||||
|
...yield,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.method;
|
||||||
|
|
||||||
|
var iter = gen();
|
||||||
|
|
||||||
|
var iter = gen();
|
||||||
|
|
||||||
|
iter.next();
|
||||||
|
iter.next();
|
||||||
|
iter.next({ x: 10, a: 0, b: 0 });
|
||||||
|
iter.next({ y: 20, a: 1, b: 1 });
|
||||||
|
var item = iter.next({ z: 30, b: 2 });
|
||||||
|
|
||||||
|
assert.sameValue(item.done, false);
|
||||||
|
assert.sameValue(item.value.x, 10);
|
||||||
|
assert.sameValue(item.value.y, 20);
|
||||||
|
assert.sameValue(item.value.z, 30);
|
||||||
|
assert.sameValue(item.value.a, 1);
|
||||||
|
assert.sameValue(item.value.b, 2);
|
||||||
|
assert.sameValue(Object.keys(item.value).length, 5);
|
||||||
|
|
||||||
|
assert.sameValue(callCount, 1);
|
|
@ -0,0 +1,44 @@
|
||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/generators/yield-identifier-spread-strict.case
|
||||||
|
// - src/generators/default/method-definition.template
|
||||||
|
/*---
|
||||||
|
description: It's an early error if the AssignmentExpression is a function body with yield as an identifier in strict mode. (Generator method)
|
||||||
|
esid: prod-GeneratorMethod
|
||||||
|
features: [object-spread]
|
||||||
|
flags: [generated, onlyStrict]
|
||||||
|
negative:
|
||||||
|
phase: early
|
||||||
|
type: SyntaxError
|
||||||
|
info: |
|
||||||
|
14.4 Generator Function Definitions
|
||||||
|
|
||||||
|
GeneratorMethod[Yield, Await]:
|
||||||
|
* PropertyName[?Yield, ?Await] ( UniqueFormalParameters[+Yield, ~Await] ) { GeneratorBody }
|
||||||
|
|
||||||
|
Spread Properties
|
||||||
|
|
||||||
|
PropertyDefinition[Yield]:
|
||||||
|
(...)
|
||||||
|
...AssignmentExpression[In, ?Yield]
|
||||||
|
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var callCount = 0;
|
||||||
|
|
||||||
|
var gen = {
|
||||||
|
*method() {
|
||||||
|
callCount += 1;
|
||||||
|
return {
|
||||||
|
...(function() {
|
||||||
|
var yield;
|
||||||
|
throw new Test262Error();
|
||||||
|
}()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.method;
|
||||||
|
|
||||||
|
var iter = gen();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
assert.sameValue(callCount, 1);
|
|
@ -0,0 +1,34 @@
|
||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/generators/yield-identifier-strict.case
|
||||||
|
// - src/generators/default/method-definition.template
|
||||||
|
/*---
|
||||||
|
description: It's an early error if the generator body has another function body with yield as an identifier in strict mode. (Generator method)
|
||||||
|
esid: prod-GeneratorMethod
|
||||||
|
flags: [generated, onlyStrict]
|
||||||
|
negative:
|
||||||
|
phase: early
|
||||||
|
type: SyntaxError
|
||||||
|
info: |
|
||||||
|
14.4 Generator Function Definitions
|
||||||
|
|
||||||
|
GeneratorMethod[Yield, Await]:
|
||||||
|
* PropertyName[?Yield, ?Await] ( UniqueFormalParameters[+Yield, ~Await] ) { GeneratorBody }
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var callCount = 0;
|
||||||
|
|
||||||
|
var gen = {
|
||||||
|
*method() {
|
||||||
|
callCount += 1;
|
||||||
|
(function() {
|
||||||
|
var yield;
|
||||||
|
throw new Test262Error();
|
||||||
|
}())
|
||||||
|
}
|
||||||
|
}.method;
|
||||||
|
|
||||||
|
var iter = gen();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
assert.sameValue(callCount, 1);
|
|
@ -0,0 +1,42 @@
|
||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/generators/yield-spread-arr-multiple.case
|
||||||
|
// - src/generators/default/method-definition.template
|
||||||
|
/*---
|
||||||
|
description: Use yield value in a array spread position (Generator method)
|
||||||
|
esid: prod-GeneratorMethod
|
||||||
|
flags: [generated]
|
||||||
|
includes: [compareArray.js]
|
||||||
|
info: |
|
||||||
|
14.4 Generator Function Definitions
|
||||||
|
|
||||||
|
GeneratorMethod[Yield, Await]:
|
||||||
|
* PropertyName[?Yield, ?Await] ( UniqueFormalParameters[+Yield, ~Await] ) { GeneratorBody }
|
||||||
|
|
||||||
|
Array Initializer
|
||||||
|
|
||||||
|
SpreadElement[Yield, Await]:
|
||||||
|
...AssignmentExpression[+In, ?Yield, ?Await]
|
||||||
|
|
||||||
|
---*/
|
||||||
|
var arr = ['a', 'b', 'c'];
|
||||||
|
var item;
|
||||||
|
|
||||||
|
var callCount = 0;
|
||||||
|
|
||||||
|
var gen = {
|
||||||
|
*method() {
|
||||||
|
callCount += 1;
|
||||||
|
yield [...yield yield];
|
||||||
|
}
|
||||||
|
}.method;
|
||||||
|
|
||||||
|
var iter = gen();
|
||||||
|
|
||||||
|
iter.next(false);
|
||||||
|
item = iter.next(['a', 'b', 'c']);
|
||||||
|
item = iter.next(item.value);
|
||||||
|
|
||||||
|
assert(compareArray(item.value, arr));
|
||||||
|
assert.sameValue(item.done, false);
|
||||||
|
|
||||||
|
assert.sameValue(callCount, 1);
|
|
@ -0,0 +1,40 @@
|
||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/generators/yield-spread-arr-single.case
|
||||||
|
// - src/generators/default/method-definition.template
|
||||||
|
/*---
|
||||||
|
description: Use yield value in a array spread position (Generator method)
|
||||||
|
esid: prod-GeneratorMethod
|
||||||
|
flags: [generated]
|
||||||
|
includes: [compareArray.js]
|
||||||
|
info: |
|
||||||
|
14.4 Generator Function Definitions
|
||||||
|
|
||||||
|
GeneratorMethod[Yield, Await]:
|
||||||
|
* PropertyName[?Yield, ?Await] ( UniqueFormalParameters[+Yield, ~Await] ) { GeneratorBody }
|
||||||
|
|
||||||
|
Array Initializer
|
||||||
|
|
||||||
|
SpreadElement[Yield, Await]:
|
||||||
|
...AssignmentExpression[+In, ?Yield, ?Await]
|
||||||
|
|
||||||
|
---*/
|
||||||
|
var arr = ['a', 'b', 'c'];
|
||||||
|
|
||||||
|
var callCount = 0;
|
||||||
|
|
||||||
|
var gen = {
|
||||||
|
*method() {
|
||||||
|
callCount += 1;
|
||||||
|
yield [...yield];
|
||||||
|
}
|
||||||
|
}.method;
|
||||||
|
|
||||||
|
var iter = gen();
|
||||||
|
|
||||||
|
iter.next(false);
|
||||||
|
var item = iter.next(['a', 'b', 'c']);
|
||||||
|
|
||||||
|
assert(compareArray(item.value, arr));
|
||||||
|
assert.sameValue(item.done, false);
|
||||||
|
|
||||||
|
assert.sameValue(callCount, 1);
|
|
@ -0,0 +1,49 @@
|
||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/generators/yield-spread-obj.case
|
||||||
|
// - src/generators/default/method-definition.template
|
||||||
|
/*---
|
||||||
|
description: Use yield value in a object spread position (Generator method)
|
||||||
|
esid: prod-GeneratorMethod
|
||||||
|
features: [object-spread]
|
||||||
|
flags: [generated]
|
||||||
|
includes: [compareArray.js]
|
||||||
|
info: |
|
||||||
|
14.4 Generator Function Definitions
|
||||||
|
|
||||||
|
GeneratorMethod[Yield, Await]:
|
||||||
|
* PropertyName[?Yield, ?Await] ( UniqueFormalParameters[+Yield, ~Await] ) { GeneratorBody }
|
||||||
|
|
||||||
|
Spread Properties
|
||||||
|
|
||||||
|
PropertyDefinition[Yield]:
|
||||||
|
(...)
|
||||||
|
...AssignmentExpression[In, ?Yield]
|
||||||
|
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var callCount = 0;
|
||||||
|
|
||||||
|
var gen = {
|
||||||
|
*method() {
|
||||||
|
callCount += 1;
|
||||||
|
yield {
|
||||||
|
...yield,
|
||||||
|
y: 1,
|
||||||
|
...yield yield,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}.method;
|
||||||
|
|
||||||
|
var iter = gen();
|
||||||
|
|
||||||
|
iter.next();
|
||||||
|
iter.next({ x: 42 });
|
||||||
|
iter.next({ x: 'lol' });
|
||||||
|
var item = iter.next({ y: 39 });
|
||||||
|
|
||||||
|
assert.sameValue(item.value.x, 42);
|
||||||
|
assert.sameValue(item.value.y, 39);
|
||||||
|
assert.sameValue(Object.keys(item.value).length, 2);
|
||||||
|
assert.sameValue(item.done, false);
|
||||||
|
|
||||||
|
assert.sameValue(callCount, 1);
|
|
@ -0,0 +1,37 @@
|
||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/generators/yield-identifier-non-strict.case
|
||||||
|
// - src/generators/non-strict/statement.template
|
||||||
|
/*---
|
||||||
|
description: Use of yield as a valid identifier in a function body inside a generator body in non strict mode (Generator function declaration - valid for non-strict only cases)
|
||||||
|
esid: prod-GeneratorDeclaration
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: |
|
||||||
|
14.4 Generator Function Definitions
|
||||||
|
|
||||||
|
GeneratorDeclaration[Yield, Await, Default]:
|
||||||
|
function * BindingIdentifier[?Yield, ?Await] ( FormalParameters[+Yield, ~Await] ) { GeneratorBody }
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var callCount = 0;
|
||||||
|
|
||||||
|
function *gen() {
|
||||||
|
callCount += 1;
|
||||||
|
return (function(arg) {
|
||||||
|
var yield = arg + 1;
|
||||||
|
return yield;
|
||||||
|
}(yield))
|
||||||
|
}
|
||||||
|
|
||||||
|
var iter = gen();
|
||||||
|
|
||||||
|
var item = iter.next();
|
||||||
|
|
||||||
|
assert.sameValue(item.done, false);
|
||||||
|
assert.sameValue(item.value, undefined);
|
||||||
|
|
||||||
|
item = iter.next(42);
|
||||||
|
|
||||||
|
assert.sameValue(item.done, true);
|
||||||
|
assert.sameValue(item.value, 43);
|
||||||
|
|
||||||
|
assert.sameValue(callCount, 1);
|
|
@ -0,0 +1,55 @@
|
||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/generators/yield-identifier-spread-non-strict.case
|
||||||
|
// - src/generators/non-strict/statement.template
|
||||||
|
/*---
|
||||||
|
description: Mixed use of object spread and yield as a valid identifier in a function body inside a generator body in non strict mode (Generator function declaration - valid for non-strict only cases)
|
||||||
|
esid: prod-GeneratorDeclaration
|
||||||
|
features: [object-spread]
|
||||||
|
flags: [generated, noStrict]
|
||||||
|
info: |
|
||||||
|
14.4 Generator Function Definitions
|
||||||
|
|
||||||
|
GeneratorDeclaration[Yield, Await, Default]:
|
||||||
|
function * BindingIdentifier[?Yield, ?Await] ( FormalParameters[+Yield, ~Await] ) { GeneratorBody }
|
||||||
|
|
||||||
|
Spread Properties
|
||||||
|
|
||||||
|
PropertyDefinition[Yield]:
|
||||||
|
(...)
|
||||||
|
...AssignmentExpression[In, ?Yield]
|
||||||
|
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var callCount = 0;
|
||||||
|
|
||||||
|
function *gen() {
|
||||||
|
callCount += 1;
|
||||||
|
yield {
|
||||||
|
...yield yield,
|
||||||
|
...(function(arg) {
|
||||||
|
var yield = arg;
|
||||||
|
return {...yield};
|
||||||
|
}(yield)),
|
||||||
|
...yield,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var iter = gen();
|
||||||
|
|
||||||
|
var iter = gen();
|
||||||
|
|
||||||
|
iter.next();
|
||||||
|
iter.next();
|
||||||
|
iter.next({ x: 10, a: 0, b: 0 });
|
||||||
|
iter.next({ y: 20, a: 1, b: 1 });
|
||||||
|
var item = iter.next({ z: 30, b: 2 });
|
||||||
|
|
||||||
|
assert.sameValue(item.done, false);
|
||||||
|
assert.sameValue(item.value.x, 10);
|
||||||
|
assert.sameValue(item.value.y, 20);
|
||||||
|
assert.sameValue(item.value.z, 30);
|
||||||
|
assert.sameValue(item.value.a, 1);
|
||||||
|
assert.sameValue(item.value.b, 2);
|
||||||
|
assert.sameValue(Object.keys(item.value).length, 5);
|
||||||
|
|
||||||
|
assert.sameValue(callCount, 1);
|
|
@ -0,0 +1,42 @@
|
||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/generators/yield-identifier-spread-strict.case
|
||||||
|
// - src/generators/default/statement.template
|
||||||
|
/*---
|
||||||
|
description: It's an early error if the AssignmentExpression is a function body with yield as an identifier in strict mode. (Generator function declaration)
|
||||||
|
esid: prod-GeneratorDeclaration
|
||||||
|
features: [object-spread]
|
||||||
|
flags: [generated, onlyStrict]
|
||||||
|
negative:
|
||||||
|
phase: early
|
||||||
|
type: SyntaxError
|
||||||
|
info: |
|
||||||
|
14.4 Generator Function Definitions
|
||||||
|
|
||||||
|
GeneratorDeclaration[Yield, Await, Default]:
|
||||||
|
function * BindingIdentifier[?Yield, ?Await] ( FormalParameters[+Yield, ~Await] ) { GeneratorBody }
|
||||||
|
|
||||||
|
Spread Properties
|
||||||
|
|
||||||
|
PropertyDefinition[Yield]:
|
||||||
|
(...)
|
||||||
|
...AssignmentExpression[In, ?Yield]
|
||||||
|
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var callCount = 0;
|
||||||
|
|
||||||
|
function *gen() {
|
||||||
|
callCount += 1;
|
||||||
|
return {
|
||||||
|
...(function() {
|
||||||
|
var yield;
|
||||||
|
throw new Test262Error();
|
||||||
|
}()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var iter = gen();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
assert.sameValue(callCount, 1);
|
|
@ -0,0 +1,32 @@
|
||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/generators/yield-identifier-strict.case
|
||||||
|
// - src/generators/default/statement.template
|
||||||
|
/*---
|
||||||
|
description: It's an early error if the generator body has another function body with yield as an identifier in strict mode. (Generator function declaration)
|
||||||
|
esid: prod-GeneratorDeclaration
|
||||||
|
flags: [generated, onlyStrict]
|
||||||
|
negative:
|
||||||
|
phase: early
|
||||||
|
type: SyntaxError
|
||||||
|
info: |
|
||||||
|
14.4 Generator Function Definitions
|
||||||
|
|
||||||
|
GeneratorDeclaration[Yield, Await, Default]:
|
||||||
|
function * BindingIdentifier[?Yield, ?Await] ( FormalParameters[+Yield, ~Await] ) { GeneratorBody }
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var callCount = 0;
|
||||||
|
|
||||||
|
function *gen() {
|
||||||
|
callCount += 1;
|
||||||
|
(function() {
|
||||||
|
var yield;
|
||||||
|
throw new Test262Error();
|
||||||
|
}())
|
||||||
|
}
|
||||||
|
|
||||||
|
var iter = gen();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
assert.sameValue(callCount, 1);
|
|
@ -0,0 +1,40 @@
|
||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/generators/yield-spread-arr-multiple.case
|
||||||
|
// - src/generators/default/statement.template
|
||||||
|
/*---
|
||||||
|
description: Use yield value in a array spread position (Generator function declaration)
|
||||||
|
esid: prod-GeneratorDeclaration
|
||||||
|
flags: [generated]
|
||||||
|
includes: [compareArray.js]
|
||||||
|
info: |
|
||||||
|
14.4 Generator Function Definitions
|
||||||
|
|
||||||
|
GeneratorDeclaration[Yield, Await, Default]:
|
||||||
|
function * BindingIdentifier[?Yield, ?Await] ( FormalParameters[+Yield, ~Await] ) { GeneratorBody }
|
||||||
|
|
||||||
|
Array Initializer
|
||||||
|
|
||||||
|
SpreadElement[Yield, Await]:
|
||||||
|
...AssignmentExpression[+In, ?Yield, ?Await]
|
||||||
|
|
||||||
|
---*/
|
||||||
|
var arr = ['a', 'b', 'c'];
|
||||||
|
var item;
|
||||||
|
|
||||||
|
var callCount = 0;
|
||||||
|
|
||||||
|
function *gen() {
|
||||||
|
callCount += 1;
|
||||||
|
yield [...yield yield];
|
||||||
|
}
|
||||||
|
|
||||||
|
var iter = gen();
|
||||||
|
|
||||||
|
iter.next(false);
|
||||||
|
item = iter.next(['a', 'b', 'c']);
|
||||||
|
item = iter.next(item.value);
|
||||||
|
|
||||||
|
assert(compareArray(item.value, arr));
|
||||||
|
assert.sameValue(item.done, false);
|
||||||
|
|
||||||
|
assert.sameValue(callCount, 1);
|
|
@ -0,0 +1,38 @@
|
||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/generators/yield-spread-arr-single.case
|
||||||
|
// - src/generators/default/statement.template
|
||||||
|
/*---
|
||||||
|
description: Use yield value in a array spread position (Generator function declaration)
|
||||||
|
esid: prod-GeneratorDeclaration
|
||||||
|
flags: [generated]
|
||||||
|
includes: [compareArray.js]
|
||||||
|
info: |
|
||||||
|
14.4 Generator Function Definitions
|
||||||
|
|
||||||
|
GeneratorDeclaration[Yield, Await, Default]:
|
||||||
|
function * BindingIdentifier[?Yield, ?Await] ( FormalParameters[+Yield, ~Await] ) { GeneratorBody }
|
||||||
|
|
||||||
|
Array Initializer
|
||||||
|
|
||||||
|
SpreadElement[Yield, Await]:
|
||||||
|
...AssignmentExpression[+In, ?Yield, ?Await]
|
||||||
|
|
||||||
|
---*/
|
||||||
|
var arr = ['a', 'b', 'c'];
|
||||||
|
|
||||||
|
var callCount = 0;
|
||||||
|
|
||||||
|
function *gen() {
|
||||||
|
callCount += 1;
|
||||||
|
yield [...yield];
|
||||||
|
}
|
||||||
|
|
||||||
|
var iter = gen();
|
||||||
|
|
||||||
|
iter.next(false);
|
||||||
|
var item = iter.next(['a', 'b', 'c']);
|
||||||
|
|
||||||
|
assert(compareArray(item.value, arr));
|
||||||
|
assert.sameValue(item.done, false);
|
||||||
|
|
||||||
|
assert.sameValue(callCount, 1);
|
|
@ -0,0 +1,47 @@
|
||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/generators/yield-spread-obj.case
|
||||||
|
// - src/generators/default/statement.template
|
||||||
|
/*---
|
||||||
|
description: Use yield value in a object spread position (Generator function declaration)
|
||||||
|
esid: prod-GeneratorDeclaration
|
||||||
|
features: [object-spread]
|
||||||
|
flags: [generated]
|
||||||
|
includes: [compareArray.js]
|
||||||
|
info: |
|
||||||
|
14.4 Generator Function Definitions
|
||||||
|
|
||||||
|
GeneratorDeclaration[Yield, Await, Default]:
|
||||||
|
function * BindingIdentifier[?Yield, ?Await] ( FormalParameters[+Yield, ~Await] ) { GeneratorBody }
|
||||||
|
|
||||||
|
Spread Properties
|
||||||
|
|
||||||
|
PropertyDefinition[Yield]:
|
||||||
|
(...)
|
||||||
|
...AssignmentExpression[In, ?Yield]
|
||||||
|
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var callCount = 0;
|
||||||
|
|
||||||
|
function *gen() {
|
||||||
|
callCount += 1;
|
||||||
|
yield {
|
||||||
|
...yield,
|
||||||
|
y: 1,
|
||||||
|
...yield yield,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
var iter = gen();
|
||||||
|
|
||||||
|
iter.next();
|
||||||
|
iter.next({ x: 42 });
|
||||||
|
iter.next({ x: 'lol' });
|
||||||
|
var item = iter.next({ y: 39 });
|
||||||
|
|
||||||
|
assert.sameValue(item.value.x, 42);
|
||||||
|
assert.sameValue(item.value.y, 39);
|
||||||
|
assert.sameValue(Object.keys(item.value).length, 2);
|
||||||
|
assert.sameValue(item.done, false);
|
||||||
|
|
||||||
|
assert.sameValue(callCount, 1);
|
Loading…
Reference in New Issue