async-gen-yield-identifier-spread-non-strict.js (1747B)
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-obj-method.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 (Generator method - valid for non-strict only cases) 7 esid: prod-AsyncGeneratorMethod 8 features: [object-spread, Symbol, async-iteration] 9 flags: [generated, noStrict, async] 10 info: | 11 Async Generator Function Definitions 12 13 AsyncGeneratorMethod : 14 async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } 15 16 17 Spread Properties 18 19 PropertyDefinition[Yield]: 20 (...) 21 ...AssignmentExpression[In, ?Yield] 22 23 ---*/ 24 var s = Symbol('s'); 25 26 27 var callCount = 0; 28 29 var gen = { 30 async *method() { 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 }.method; 42 43 var iter = gen(); 44 45 var iter = gen(); 46 47 iter.next(); 48 iter.next(); 49 iter.next({ x: 10, a: 0, b: 0, [s]: 1 }); 50 iter.next({ y: 20, a: 1, b: 1, [s]: 42 }); 51 var item = iter.next({ z: 30, b: 2 }); 52 53 item.then(({ done, value }) => { 54 assert.sameValue(done, false); 55 assert.sameValue(value.x, 10); 56 assert.sameValue(value.y, 20); 57 assert.sameValue(value.z, 30); 58 assert.sameValue(value.a, 1); 59 assert.sameValue(value.b, 2); 60 assert.sameValue(value[s], 42); 61 assert.sameValue(Object.keys(value).length, 5); 62 assert(Object.prototype.hasOwnProperty.call(value, s), "s is an own property"); 63 }).then($DONE, $DONE); 64 65 assert.sameValue(callCount, 1);