Debian Codegraph @

js/src/tests/test262/language/statements/async-generator/yield-promise-reject-next-yield-star-async-iterator.js

raw
1 // |reftest| async
2 // This file was procedurally generated from the following sources:
3 // - src/async-generators/yield-promise-reject-next-yield-star-async-iterator.case
4 // - src/async-generators/default/async-declaration.template
5 /*---
6 description: yield * (async iterator) is treated as throw value (Async generator Function declaration)
7 esid: prod-AsyncGeneratorDeclaration
8 features: [async-iteration]
9 flags: [generated, async]
10 info: |
11 Async Generator Function Definitions
12
13 AsyncGeneratorDeclaration:
14 async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) {
15 AsyncGeneratorBody }
16
17 ---*/
18 let error = new Error();
19 async function * readFile() {
20 yield Promise.reject(error);
21 yield "unreachable";
22 }
23
24
25 var callCount = 0;
26
27 async function *gen() {
28 callCount += 1;
29 yield * readFile();
30
31 }
32
33 var iter = gen();
34
35 iter.next().then(() => {
36 throw new Test262Error("Promise incorrectly resolved.");
37 }, rejectValue => {
38 // yield Promise.reject(error);
39 assert.sameValue(rejectValue, error);
40
41 iter.next().then(({done, value}) => {
42 // iter is closed now.
43 assert.sameValue(done, true, "The value of IteratorResult.done is `true`");
44 assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`");
45 }).then($DONE, $DONE);
46 }, $DONE).catch($DONE);
47
48 assert.sameValue(callCount, 1);