js/src/tests/test262/language/expressions/async-generator/named-yield-star-next-not-callable-undefined-throw.js
raw symbols SCIP| 1 | // |reftest| async |
| 2 | // This file was procedurally generated from the following sources: |
| 3 | // - src/async-generators/yield-star-next-not-callable-undefined-throw.case |
| 4 | // - src/async-generators/default/async-expression-named.template |
| 5 | /*--- |
| 6 | description: Not-callable next value in a yield star position - undefined (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 | 6. Repeat |
| 21 | a. If received.[[Type]] is normal, then |
| 22 | ii. Let innerResult be ? Invoke(iterator, "next", |
| 23 | « received.[[Value]] »). |
| 24 | ... |
| 25 | |
| 26 | ---*/ |
| 27 | var obj = { |
| 28 | get [Symbol.iterator]() { |
| 29 | throw new Test262Error('it should not get Symbol.iterator'); |
| 30 | }, |
| 31 | [Symbol.asyncIterator]() { |
| 32 | return { |
| 33 | next: undefined |
| 34 | }; |
| 35 | } |
| 36 | }; |
| 37 | |
| 38 | |
| 39 | |
| 40 | var callCount = 0; |
| 41 | |
| 42 | var gen = async function *g() { |
| 43 | callCount += 1; |
| 44 | yield* obj; |
| 45 | throw new Test262Error('abrupt completion closes iter'); |
| 46 | |
| 47 | }; |
| 48 | |
| 49 | var iter = gen(); |
| 50 | |
| 51 | iter.next().then(() => { |
| 52 | throw new Test262Error('Promise incorrectly fulfilled.'); |
| 53 | }, v => { |
| 54 | assert.sameValue(v.constructor, TypeError, "TypeError"); |
| 55 | |
| 56 | iter.next().then(({ done, value }) => { |
| 57 | assert.sameValue(done, true, 'the iterator is completed'); |
| 58 | assert.sameValue(value, undefined, 'value is undefined'); |
| 59 | }).then($DONE, $DONE); |
| 60 | }).catch($DONE); |
| 61 | |
| 62 | assert.sameValue(callCount, 1); |