| 1 |
// This file was procedurally generated from the following sources: |
| 2 |
// - src/generators/yield-identifier-spread-non-strict.case |
| 3 |
// - src/generators/non-strict/obj-method.template |
| 4 |
/*--- |
| 5 |
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) |
| 6 |
esid: prod-GeneratorMethod |
| 7 |
features: [Symbol, object-spread, generators] |
| 8 |
flags: [generated, noStrict] |
| 9 |
info: | |
| 10 |
14.4 Generator Function Definitions |
| 11 |
|
| 12 |
GeneratorMethod[Yield, Await]: |
| 13 |
* PropertyName ( UniqueFormalParameters ) { GeneratorBody } |
| 14 |
|
| 15 |
|
| 16 |
Spread Properties |
| 17 |
|
| 18 |
PropertyDefinition[Yield]: |
| 19 |
(...) |
| 20 |
...AssignmentExpression[In, ?Yield] |
| 21 |
|
| 22 |
---*/ |
| 23 |
var s = Symbol('s'); |
| 24 |
|
| 25 |
var callCount = 0; |
| 26 |
|
| 27 |
var gen = { |
| 28 |
*method() { |
| 29 |
callCount += 1; |
| 30 |
yield { |
| 31 |
...yield yield, |
| 32 |
...(function(arg) { |
| 33 |
var yield = arg; |
| 34 |
return {...yield}; |
| 35 |
}(yield)), |
| 36 |
...yield, |
| 37 |
} |
| 38 |
} |
| 39 |
}.method; |
| 40 |
|
| 41 |
var iter = gen(); |
| 42 |
|
| 43 |
var iter = gen(); |
| 44 |
|
| 45 |
iter.next(); |
| 46 |
iter.next(); |
| 47 |
iter.next({ x: 10, a: 0, b: 0, [s]: 1 }); |
| 48 |
iter.next({ y: 20, a: 1, b: 1, [s]: 42 }); |
| 49 |
var item = iter.next({ z: 30, b: 2 }); |
| 50 |
|
| 51 |
var value = item.value; |
| 52 |
|
| 53 |
assert.sameValue(item.done, false); |
| 54 |
assert.sameValue(value.x, 10); |
| 55 |
assert.sameValue(value.y, 20); |
| 56 |
assert.sameValue(value.z, 30); |
| 57 |
assert.sameValue(value.a, 1); |
| 58 |
assert.sameValue(value.b, 2); |
| 59 |
assert.sameValue(value[s], 42); |
| 60 |
assert(Object.hasOwnProperty.call(value, s)); |
| 61 |
assert.sameValue(Object.keys(value).length, 5); |
| 62 |
|
| 63 |
assert.sameValue(callCount, 1); |