Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/language/expressions/object/method-definition/async-gen-yield-star-next-call-done-get-abrupt.js

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