yield-identifier-spread-non-strict.js (1755B)
1 // |reftest| async 2 // This file was procedurally generated from the following sources: 3 // - src/async-generators/yield-identifier-spread-non-strict.case 4 // - src/async-generators/non-strict/async-declaration.template 5 /*--- 6 description: Mixed use of object spread and yield as a valid identifier in a function body inside a generator body in non strict mode (Async generator function declaration - valid for non-strict only cases) 7 esid: prod-AsyncGeneratorDeclaration 8 features: [object-spread, Symbol, async-iteration] 9 flags: [generated, noStrict, async] 10 info: | 11 Async Generator Function Definitions 12 13 AsyncGeneratorDeclaration: 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 var s = Symbol('s'); 26 27 28 var callCount = 0; 29 30 async function *gen() { 31 callCount += 1; 32 yield { 33 ...yield yield, 34 ...(function(arg) { 35 var yield = arg; 36 return {...yield}; 37 }(yield)), 38 ...yield, 39 } 40 } 41 42 var iter = gen(); 43 44 var iter = gen(); 45 46 iter.next(); 47 iter.next(); 48 iter.next({ x: 10, a: 0, b: 0, [s]: 1 }); 49 iter.next({ y: 20, a: 1, b: 1, [s]: 42 }); 50 var item = iter.next({ z: 30, b: 2 }); 51 52 item.then(({ done, value }) => { 53 assert.sameValue(done, false); 54 assert.sameValue(value.x, 10); 55 assert.sameValue(value.y, 20); 56 assert.sameValue(value.z, 30); 57 assert.sameValue(value.a, 1); 58 assert.sameValue(value.b, 2); 59 assert.sameValue(value[s], 42); 60 assert.sameValue(Object.keys(value).length, 5); 61 assert(Object.prototype.hasOwnProperty.call(value, s), "s is an own property"); 62 }).then($DONE, $DONE); 63 64 assert.sameValue(callCount, 1);