js/src/tests/test262/language/expressions/class/async-gen-method/yield-star-next-not-callable-symbol-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-symbol-throw.case |
| 4 | // - src/async-generators/default/async-class-expr-method.template |
| 5 | /*--- |
| 6 | description: Not-callable next value in a yield star position - symbol (Async generator method as a ClassExpression element) |
| 7 | esid: prod-AsyncGeneratorMethod |
| 8 | features: [Symbol.iterator, Symbol.asyncIterator, async-iteration] |
| 9 | flags: [generated, async] |
| 10 | info: | |
| 11 | ClassElement : |
| 12 | MethodDefinition |
| 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: Symbol('oi') |
| 39 | }; |
| 40 | } |
| 41 | }; |
| 42 | |
| 43 | |
| 44 | |
| 45 | var callCount = 0; |
| 46 | |
| 47 | var C = class { async *gen() { |
| 48 | callCount += 1; |
| 49 | yield* obj; |
| 50 | throw new Test262Error('abrupt completion closes iter'); |
| 51 | |
| 52 | }} |
| 53 | |
| 54 | var gen = C.prototype.gen; |
| 55 | |
| 56 | var iter = gen(); |
| 57 | |
| 58 | iter.next().then(() => { |
| 59 | throw new Test262Error('Promise incorrectly fulfilled.'); |
| 60 | }, v => { |
| 61 | assert.sameValue(v.constructor, TypeError, "TypeError"); |
| 62 | |
| 63 | iter.next().then(({ done, value }) => { |
| 64 | assert.sameValue(done, true, 'the iterator is completed'); |
| 65 | assert.sameValue(value, undefined, 'value is undefined'); |
| 66 | }).then($DONE, $DONE); |
| 67 | }).catch($DONE); |
| 68 | |
| 69 | assert.sameValue(callCount, 1); |