Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/language/expressions/class/async-gen-method-yield-star-next-not-callable-number-throw.js

raw
1 // This file was procedurally generated from the following sources:
2 // - src/async-generators/yield-star-next-not-callable-number-throw.case
3 // - src/async-generators/default/async-class-expr-method.template
4 /*---
5 description: Not-callable next value in a yield star position - number (Async generator method as a ClassExpression element)
6 esid: prod-AsyncGeneratorMethod
7 features: [Symbol.iterator, Symbol.asyncIterator, async-iteration]
8 flags: [generated, async]
9 info: |
10 ClassElement :
11 MethodDefinition
12
13 MethodDefinition :
14 AsyncGeneratorMethod
15
16 Async Generator Function Definitions
17
18 AsyncGeneratorMethod :
19 async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody }
20
21
22 YieldExpression: yield * AssignmentExpression
23 ...
24 6. Repeat
25 a. If received.[[Type]] is normal, then
26 ii. Let innerResult be ? Invoke(iterator, "next",
27 « received.[[Value]] »).
28 ...
29
30 ---*/
31 var obj = {
32 get [Symbol.iterator]() {
33 throw new Test262Error('it should not get Symbol.iterator');
34 },
35 [Symbol.asyncIterator]() {
36 return {
37 next: 42
38 };
39 }
40 };
41
42
43
44 var callCount = 0;
45
46 var C = class { async *gen() {
47 callCount += 1;
48 yield* obj;
49 throw new Test262Error('abrupt completion closes iter');
50
51 }}
52
53 var gen = C.prototype.gen;
54
55 var iter = gen();
56
57 iter.next().then(() => {
58 throw new Test262Error('Promise incorrectly fulfilled.');
59 }, v => {
60 assert.sameValue(v.constructor, TypeError, "TypeError");
61
62 iter.next().then(({ done, value }) => {
63 assert.sameValue(done, true, 'the iterator is completed');
64 assert.sameValue(value, undefined, 'value is undefined');
65 }).then($DONE, $DONE);
66 }).catch($DONE);
67
68 assert.sameValue(callCount, 1);