mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-16 15:51:35 -05:00
Fix asyncDelegator reporting "done" too early (#51274)
* Fix asyncDelegator reporting done too early * Add unit test for yields inside finally block See #45400
This commit is contained in:
@@ -30,4 +30,30 @@ describe("unittests:: evaluation:: asyncGeneratorEvaluation", () => {
|
||||
{ value: 0, done: true }
|
||||
]);
|
||||
});
|
||||
it("yields in finally block with async delegator (es2017)", async () => {
|
||||
const result = evaluator.evaluateTypeScript(`
|
||||
async function* g1() {
|
||||
try {
|
||||
yield 1;
|
||||
} finally {
|
||||
yield 2;
|
||||
}
|
||||
}
|
||||
async function* g2() {
|
||||
yield* g1();
|
||||
}
|
||||
export const output: any[] = [];
|
||||
export async function main() {
|
||||
const it = g2();
|
||||
output.push(await it.next());
|
||||
output.push(await it.return());
|
||||
output.push(await it.next());
|
||||
}`, { target: ts.ScriptTarget.ES2017 });
|
||||
await result.main();
|
||||
assert.deepEqual(result.output, [
|
||||
{ done: false, value: 1 },
|
||||
{ done: false, value: 2 },
|
||||
{ done: true, value: undefined }
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user