accessor-name-inst-computed-yield-expr.js (1150B)
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 [...] 10 21. For each ClassElement m in order from methods 11 a. If IsStatic of m is false, then 12 i. Let status be the result of performing PropertyDefinitionEvaluation 13 for m with arguments proto and false. 14 15 ComputedPropertyName : [ AssignmentExpression ] 16 17 1. Let exprValue be the result of evaluating AssignmentExpression. 18 2. Let propName be ? GetValue(exprValue). 19 3. Return ? ToPropertyKey(propName). 20 features: [generators] 21 ---*/ 22 23 var yieldSet, C, iter; 24 function* g() { 25 C = class { 26 get [yield]() { return 'get yield'; } 27 set [yield](param) { yieldSet = param; } 28 }; 29 } 30 31 iter = g(); 32 33 iter.next(); 34 iter.next('first'); 35 iter.next('second'); 36 37 assert.sameValue(C.prototype.first, 'get yield'); 38 39 C.prototype.second = 'set yield'; 40 41 assert.sameValue(yieldSet, 'set yield'); 42 43 reportCompare(0, 0);