Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/language/expressions/class/async-gen-method-static-yield-promise-reject-next-yield-star-async-iterator.js

raw
1 // This file was procedurally generated from the following sources:
2 // - src/async-generators/yield-promise-reject-next-yield-star-async-iterator.case
3 // - src/async-generators/default/async-class-expr-static-method.template
4 /*---
5 description: yield * (async iterator) is treated as throw value (Static async generator method as a ClassExpression element)
6 esid: prod-AsyncGeneratorMethod
7 features: [async-iteration]
8 flags: [generated, async]
9 info: |
10 ClassElement :
11 static 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 let error = new Error();
23 async function * readFile() {
24 yield Promise.reject(error);
25 yield "unreachable";
26 }
27
28
29 var callCount = 0;
30
31 var C = class { static async *gen() {
32 callCount += 1;
33 yield * readFile();
34
35 }}
36
37 var gen = C.gen;
38
39 var iter = gen();
40
41 iter.next().then(() => {
42 throw new Test262Error("Promise incorrectly resolved.");
43 }, rejectValue => {
44 // yield Promise.reject(error);
45 assert.sameValue(rejectValue, error);
46
47 iter.next().then(({done, value}) => {
48 // iter is closed now.
49 assert.sameValue(done, true, "The value of IteratorResult.done is `true`");
50 assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`");
51 }).then($DONE, $DONE);
52 }, $DONE).catch($DONE);
53
54 assert.sameValue(callCount, 1);