Debian Codegraph @

js/src/tests/test262/language/statements/async-generator/yield-promise-reject-next-yield-star-sync-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-sync-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 let iterable = [
20 Promise.reject(error),
21 "unreachable"
22 ];
23
24
25 var callCount = 0;
26
27 async function *gen() {
28 callCount += 1;
29 yield * iterable;
30 }
31
32 var iter = gen();
33
34 iter.next().then(() => {
35 throw new Test262Error("Promise incorrectly resolved.");
36 }, rejectValue => {
37 // yield Promise.reject(error);
38 assert.sameValue(rejectValue, error);
39
40 iter.next().then(({done, value}) => {
41 // iter is closed now.
42 assert.sameValue(done, true, "The value of IteratorResult.done is `true`");
43 assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`");
44 }).then($DONE, $DONE);
45 }).catch($DONE);
46
47 assert.sameValue(callCount, 1);