| 1 |
// Copyright (C) 2015 the V8 project authors. All rights reserved. |
| 2 |
// This code is governed by the BSD license found in the LICENSE file. |
| 3 |
|
| 4 |
/*--- |
| 5 |
description: > |
| 6 |
When the `yield` keyword occurs within the PropertyName of a |
| 7 |
non-generator MethodDefinition within a generator function, it behaves as a |
| 8 |
YieldExpression. |
| 9 |
es6id: 14.3 |
| 10 |
features: [generators] |
| 11 |
flags: [noStrict] |
| 12 |
---*/ |
| 13 |
|
| 14 |
var obj = null; |
| 15 |
var yield = 'propNameViaIdentifier'; |
| 16 |
var iter = (function*() { |
| 17 |
obj = { |
| 18 |
[yield]() {} |
| 19 |
}; |
| 20 |
})(); |
| 21 |
|
| 22 |
iter.next(); |
| 23 |
|
| 24 |
assert.sameValue(obj, null); |
| 25 |
|
| 26 |
iter.next('propNameViaExpression'); |
| 27 |
|
| 28 |
assert.sameValue( |
| 29 |
Object.hasOwnProperty.call(obj, 'propNameViaIdentifier'), false |
| 30 |
); |
| 31 |
assert.sameValue( |
| 32 |
Object.hasOwnProperty.call(obj, 'propNameViaExpression'), true |
| 33 |
); |