yield-spread-obj.js (1338B)
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-class-decl-method.template 5 /*--- 6 description: Use yield value in a object spread position (Async Generator method as a ClassDeclaration element) 7 esid: prod-AsyncGeneratorMethod 8 features: [object-spread, async-iteration] 9 flags: [generated, async] 10 info: | 11 ClassElement : 12 MethodDefinition 13 14 MethodDefinition : 15 AsyncGeneratorMethod 16 17 Async Generator Function Definitions 18 19 AsyncGeneratorMethod : 20 async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } 21 22 23 Spread Properties 24 25 PropertyDefinition[Yield]: 26 (...) 27 ...AssignmentExpression[In, ?Yield] 28 29 ---*/ 30 31 32 var callCount = 0; 33 34 class C { async *gen() { 35 callCount += 1; 36 yield { 37 ...yield, 38 y: 1, 39 ...yield yield, 40 }; 41 }} 42 43 var gen = C.prototype.gen; 44 45 var iter = gen(); 46 47 iter.next(); 48 iter.next({ x: 42 }); 49 iter.next({ x: 'lol' }); 50 var item = iter.next({ y: 39 }); 51 52 item.then(({ done, value }) => { 53 assert.sameValue(value.x, 42); 54 assert.sameValue(value.y, 39); 55 assert.sameValue(Object.keys(value).length, 2); 56 assert.sameValue(done, false); 57 }).then($DONE, $DONE); 58 59 assert.sameValue(callCount, 1);