Skip to content

Commit 14b5d03

Browse files
committed
Add unit test for yields inside finally block
See microsoft#45400
1 parent e39ab04 commit 14b5d03

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/testRunner/unittests/evaluation/asyncGenerator.ts

+26
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,30 @@ describe("unittests:: evaluation:: asyncGeneratorEvaluation", () => {
2727
{ value: 0, done: true }
2828
]);
2929
});
30+
it("yields in finally block with async delegator (es2017)", async () => {
31+
const result = evaluator.evaluateTypeScript(`
32+
async function* g1() {
33+
try {
34+
yield 1;
35+
} finally {
36+
yield 2;
37+
}
38+
}
39+
async function* g2() {
40+
yield* g1();
41+
}
42+
export const output: any[] = [];
43+
export async function main() {
44+
const it = g2();
45+
output.push(await it.next());
46+
output.push(await it.return());
47+
output.push(await it.next());
48+
}`, { target: ts.ScriptTarget.ES2017 });
49+
await result.main();
50+
assert.deepEqual(result.output, [
51+
{ done: false, value: 1 },
52+
{ done: false, value: 2 },
53+
{ done: true, value: undefined }
54+
]);
55+
});
3056
});

0 commit comments

Comments
 (0)