accessor-name-static-computed-yield-expr.js (1179B)
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 [...] 13 b. Else, 14 a. Let status be the result of performing PropertyDefinitionEvaluation 15 for m with arguments F and false. 16 17 ComputedPropertyName : [ AssignmentExpression ] 18 19 1. Let exprValue be the result of evaluating AssignmentExpression. 20 2. Let propName be ? GetValue(exprValue). 21 3. Return ? ToPropertyKey(propName). 22 features: [generators] 23 ---*/ 24 25 var yieldSet, C, iter; 26 function* g() { 27 class C_ { 28 static get [yield]() { return 'get yield'; } 29 static set [yield](param) { yieldSet = param; } 30 } 31 32 C = C_; 33 } 34 35 iter = g(); 36 37 iter.next(); 38 iter.next('first'); 39 iter.next('second'); 40 41 assert.sameValue(C.first, 'get yield'); 42 43 C.second = 'set yield'; 44 45 assert.sameValue(yieldSet, 'set yield'); 46 47 reportCompare(0, 0);