yield-spread-obj.js (1209B)
1 // |reftest| async 2 // This file was procedurally generated from the following sources: 3 // - src/async-generators/yield-spread-obj.case 4 // - src/async-generators/default/async-expression.template 5 /*--- 6 description: Use yield value in a object spread position (Unnamed async generator expression) 7 esid: prod-AsyncGeneratorExpression 8 features: [object-spread, async-iteration] 9 flags: [generated, async] 10 info: | 11 Async Generator Function Definitions 12 13 AsyncGeneratorExpression : 14 async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) { 15 AsyncGeneratorBody } 16 17 18 Spread Properties 19 20 PropertyDefinition[Yield]: 21 (...) 22 ...AssignmentExpression[In, ?Yield] 23 24 ---*/ 25 26 27 var callCount = 0; 28 29 var gen = async function *() { 30 callCount += 1; 31 yield { 32 ...yield, 33 y: 1, 34 ...yield yield, 35 }; 36 }; 37 38 var iter = gen(); 39 40 iter.next(); 41 iter.next({ x: 42 }); 42 iter.next({ x: 'lol' }); 43 var item = iter.next({ y: 39 }); 44 45 item.then(({ done, value }) => { 46 assert.sameValue(value.x, 42); 47 assert.sameValue(value.y, 39); 48 assert.sameValue(Object.keys(value).length, 2); 49 assert.sameValue(done, false); 50 }).then($DONE, $DONE); 51 52 assert.sameValue(callCount, 1);