named-yield-star-getiter-async-not-callable-string-throw.js (2023B)
1 // |reftest| async 2 // This file was procedurally generated from the following sources: 3 // - src/async-generators/yield-star-getiter-async-not-callable-string-throw.case 4 // - src/async-generators/default/async-expression-named.template 5 /*--- 6 description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (string) (Named async generator expression) 7 esid: prod-AsyncGeneratorExpression 8 features: [Symbol.iterator, Symbol.asyncIterator, 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 YieldExpression: yield * AssignmentExpression 19 20 1. Let exprRef be the result of evaluating AssignmentExpression. 21 2. Let value be ? GetValue(exprRef). 22 3. Let generatorKind be ! GetGeneratorKind(). 23 4. Let iterator be ? GetIterator(value, generatorKind). 24 ... 25 26 GetIterator ( obj [ , hint ] ) 27 28 ... 29 3. If hint is async, 30 a. Set method to ? GetMethod(obj, @@asyncIterator). 31 ... 32 33 GetMethod ( V, P ) 34 35 ... 36 2. Let func be ? GetV(V, P). 37 3. If func is either undefined or null, return undefined. 38 4. If IsCallable(func) is false, throw a TypeError exception. 39 ... 40 41 ---*/ 42 var obj = { 43 get [Symbol.iterator]() { 44 throw new Test262Error('it should not get Symbol.iterator'); 45 }, 46 [Symbol.asyncIterator]: '' 47 }; 48 49 50 51 var callCount = 0; 52 53 var gen = async function *g() { 54 callCount += 1; 55 yield* obj; 56 throw new Test262Error('abrupt completion closes iter'); 57 58 }; 59 60 var iter = gen(); 61 62 iter.next().then(() => { 63 throw new Test262Error('Promise incorrectly fulfilled.'); 64 }, v => { 65 assert.sameValue(v.constructor, TypeError, "TypeError"); 66 67 iter.next().then(({ done, value }) => { 68 assert.sameValue(done, true, 'the iterator is completed'); 69 assert.sameValue(value, undefined, 'value is undefined'); 70 }).then($DONE, $DONE); 71 }).catch($DONE); 72 73 assert.sameValue(callCount, 1);