Debian Codegraph @

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

raw
1 // This file was procedurally generated from the following sources:
2 // - src/async-generators/yield-star-next-get-abrupt.case
3 // - src/async-generators/default/async-obj-method.template
4 /*---
5 description: Abrupt completion while getting next (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 ...
23
24 ---*/
25 var reason = {};
26 var obj = {
27 get [Symbol.iterator]() {
28 throw new Test262Error('it should not get Symbol.iterator');
29 },
30 [Symbol.asyncIterator]() {
31 return {
32 get next() {
33 throw reason;
34 }
35 };
36 }
37 };
38
39
40 var callCount = 0;
41
42 var gen = {
43 async *method() {
44 callCount += 1;
45 yield* obj;
46 throw new Test262Error('abrupt completion closes iter');
47
48 }
49 }.method;
50
51 var iter = gen();
52
53 iter.next().then(() => {
54 throw new Test262Error('Promise incorrectly fulfilled.');
55 }, v => {
56 assert.sameValue(v, reason, "reject reason");
57
58 iter.next().then(({ done, value }) => {
59 assert.sameValue(done, true, 'the iterator is completed');
60 assert.sameValue(value, undefined, 'value is undefined');
61 }).then($DONE, $DONE);
62 }).catch($DONE);
63
64 assert.sameValue(callCount, 1);