yield-spread-arr-multiple.js (986B)
1 // This file was procedurally generated from the following sources: 2 // - src/generators/yield-spread-arr-multiple.case 3 // - src/generators/default/declaration.template 4 /*--- 5 description: Use yield value in a array spread position (Generator Function declaration) 6 esid: prod-GeneratorDeclaration 7 features: [generators] 8 flags: [generated] 9 includes: [compareArray.js] 10 info: | 11 14.4 Generator Function Definitions 12 13 GeneratorDeclaration : 14 function * BindingIdentifier ( FormalParameters ) { GeneratorBody } 15 16 17 Array Initializer 18 19 SpreadElement[Yield, Await]: 20 ...AssignmentExpression[+In, ?Yield, ?Await] 21 22 ---*/ 23 var arr = ['a', 'b', 'c']; 24 var item; 25 26 var callCount = 0; 27 28 function *gen() { 29 callCount += 1; 30 yield [...yield yield]; 31 } 32 33 var iter = gen(); 34 35 iter.next(false); 36 item = iter.next(['a', 'b', 'c']); 37 item = iter.next(item.value); 38 39 assert.compareArray(item.value, arr); 40 assert.sameValue(item.done, false); 41 42 assert.sameValue(callCount, 1); 43 44 reportCompare(0, 0);