Debian Codegraph @

packages/babel-plugin-proposal-async-generator-functions/test/fixtures/yield-star/throw-method-with-catch/exec.js

raw
1 const log = [];
2
3 async function* inner() {
4 try {
5 log.push(1);
6 yield "a";
7 log.push(2);
8 yield "b";
9 log.push(3);
10 } catch (e) {
11 log.push(4);
12 yield "c";
13 log.push(5);
14 }
15 }
16
17 async function* outer() {
18 log.push(6);
19 yield* inner();
20 log.push(7);
21 }
22
23 return (async () => {
24 const iterator = outer();
25
26 let res = await iterator.next();
27 expect(res).toEqual({ value: "a", done: false });
28 expect(log).toEqual([6, 1]);
29
30 res = await iterator.throw(new Error("TEST"));
31 expect(res).toEqual({ value: "c", done: false });
32 expect(log).toEqual([6, 1, 4]);
33
34 res = await iterator.next();
35 expect(res).toEqual({ value: undefined, done: true });
36 expect(log).toEqual([6, 1, 4, 5, 7]);
37 })();