yield-star-next-not-callable-boolean-throw.js (2557B)
1 // |reftest| async 2 // This file was procedurally generated from the following sources: 3 // - src/async-generators/yield-star-next-not-callable-boolean-throw.case 4 // - src/async-generators/default/async-class-expr-static-private-method.template 5 /*--- 6 description: Not-callable next value in a yield star position - boolean (Static async generator method as a ClassExpression element) 7 esid: prod-AsyncGeneratorPrivateMethod 8 features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] 9 flags: [generated, async] 10 info: | 11 ClassElement : 12 static PrivateMethodDefinition 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 YieldExpression: yield * AssignmentExpression 24 ... 25 6. Repeat 26 a. If received.[[Type]] is normal, then 27 ii. Let innerResult be ? Invoke(iterator, "next", 28 « received.[[Value]] »). 29 ... 30 31 ---*/ 32 var obj = { 33 get [Symbol.iterator]() { 34 throw new Test262Error('it should not get Symbol.iterator'); 35 }, 36 [Symbol.asyncIterator]() { 37 return { 38 next: true 39 }; 40 } 41 }; 42 43 44 45 var callCount = 0; 46 47 var C = class { 48 static async *#gen() { 49 callCount += 1; 50 yield* obj; 51 throw new Test262Error('abrupt completion closes iter'); 52 53 } 54 static get gen() { return this.#gen; } 55 } 56 57 // Test the private fields do not appear as properties before set to value 58 assert( 59 !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), 60 "#gen does not appear as an own property on C prototype" 61 ); 62 assert( 63 !Object.prototype.hasOwnProperty.call(C, "#gen"), 64 "#gen does not appear as an own property on C constructor" 65 ); 66 67 var iter = C.gen(); 68 69 iter.next().then(() => { 70 throw new Test262Error('Promise incorrectly fulfilled.'); 71 }, v => { 72 assert.sameValue(v.constructor, TypeError, "TypeError"); 73 74 iter.next().then(({ done, value }) => { 75 assert.sameValue(done, true, 'the iterator is completed'); 76 assert.sameValue(value, undefined, 'value is undefined'); 77 }).then($DONE, $DONE); 78 }).catch($DONE); 79 80 assert.sameValue(callCount, 1); 81 82 // Test the private fields do not appear as properties after set to value 83 assert( 84 !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), 85 "#gen does not appear as an own property on C prototype" 86 ); 87 assert( 88 !Object.prototype.hasOwnProperty.call(C, "#gen"), 89 "#gen does not appear as an own property on C constructor" 90 );