Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/language/expressions/object/accessor-name-computed-yield-expr.js

raw
1 // Copyright (C) 2016 the V8 project authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3 /*---
4 esid: sec-object-initializer-runtime-semantics-evaluation
5 es6id: 12.2.6.8
6 description: >
7 The `yield` keyword behaves as a YieldExpression within a generator function
8 info: |
9 12.2.6.7 Runtime Semantics: Evaluation
10
11 [...]
12
13 ComputedPropertyName : [ AssignmentExpression ]
14
15 1. Let exprValue be the result of evaluating AssignmentExpression.
16 2. Let propName be ? GetValue(exprValue).
17 3. Return ? ToPropertyKey(propName).
18 features: [generators]
19 ---*/
20
21 var yieldSet, obj, iter;
22 function* g() {
23 obj = {
24 get [yield]() { return 'get yield'; },
25 set [yield](param) { yieldSet = param; }
26 };
27 }
28
29 iter = g();
30
31 iter.next();
32 iter.next('first');
33 iter.next('second');
34
35 assert.sameValue(obj.first, 'get yield');
36
37 obj.second = 'set yield';
38
39 assert.sameValue(yieldSet, 'set yield');