Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/language/expressions/class/async-gen-method-yield-star-getiter-async-get-abrupt.js

raw
1 // This file was procedurally generated from the following sources:
2 // - src/async-generators/yield-star-getiter-async-get-abrupt.case
3 // - src/async-generators/default/async-class-expr-method.template
4 /*---
5 description: Abrupt completion while getting [Symbol.asyncIterator] (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 1. Let exprRef be the result of evaluating AssignmentExpression.
25 2. Let value be ? GetValue(exprRef).
26 3. Let generatorKind be ! GetGeneratorKind().
27 4. Let iterator be ? GetIterator(value, generatorKind).
28 ...
29
30 GetIterator ( obj [ , hint ] )
31
32 ...
33 3. If hint is async,
34 a. Set method to ? GetMethod(obj, @@asyncIterator).
35 ...
36
37 GetMethod ( V, P )
38
39 ...
40 2. Let func be ? GetV(V, P).
41 ...
42
43 ---*/
44 var reason = {};
45 var obj = {
46 get [Symbol.iterator]() {
47 throw new Test262Error('it should not get Symbol.iterator');
48 },
49 get [Symbol.asyncIterator]() {
50 throw reason;
51 }
52 };
53
54
55
56 var callCount = 0;
57
58 var C = class { async *gen() {
59 callCount += 1;
60 yield* obj;
61 throw new Test262Error('abrupt completion closes iter');
62
63 }}
64
65 var gen = C.prototype.gen;
66
67 var iter = gen();
68
69 iter.next().then(() => {
70 throw new Test262Error('Promise incorrectly fulfilled.');
71 }, v => {
72 assert.sameValue(v, reason, "reject reason");
73
74 iter.next().then(({ done, value }) => {
75 assert.sameValue(done, true, 'the iterator is completed');
76 assert.sameValue(value, undefined, 'value is undefined');
77 }).then($DONE, $DONE);
78 }).catch($DONE);
79
80 assert.sameValue(callCount, 1);