rhs-template-middle.js (1314B)
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-generator-function-definitions 5 es6id: 14.4 6 description: YieldExpression may be followed by a TemplateMiddle construct 7 info: | 8 The syntactic context immediately following yield requires use of the 9 InputElementRegExpOrTemplateTail lexical goal. 10 features: [generators] 11 ---*/ 12 13 var complete = false; 14 var iter, iterResult, str; 15 function* g() { 16 str = `1${ yield }3${ 4 }5`; 17 complete = true; 18 } 19 20 iter = g(); 21 22 assert.sameValue(complete, false, 'generator initially paused'); 23 assert.sameValue(str, undefined, 'first statement not executed'); 24 25 iterResult = iter.next(); 26 27 assert.sameValue(complete, false, 'generator paused following expression'); 28 assert.sameValue(str, undefined, 'first statement not executed'); 29 30 assert.sameValue(iterResult.done, false, 'iteration not complete'); 31 assert.sameValue(iterResult.value, undefined, 'first iterated value'); 32 33 iterResult = iter.next(2); 34 35 assert.sameValue(str, '12345', 'YieldExpression value'); 36 assert.sameValue(complete, true, 'generator correctly re-started'); 37 assert.sameValue(iterResult.done, true, 'iteration complete'); 38 assert.sameValue(iterResult.value, undefined, 'second iterated value'); 39 40 reportCompare(0, 0);