Skip to content

Commit 20b205d

Browse files
committed
add multi-return test for async try
1 parent 9c85ab5 commit 20b205d

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

test/unit/builtins/async-await.spec.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -958,6 +958,27 @@ describe("try/catch in async function", () => {
958958
}
959959
);
960960

961+
// https://github.com/TypeScriptToLua/TypeScriptToLua/issues/1706
962+
test("multi return from try in async function (#1706)", () => {
963+
util.testFunction`
964+
async function fn(): Promise<LuaMultiReturn<[string, string]>> {
965+
try {
966+
await Promise.resolve();
967+
return $multi("foo", "bar");
968+
} catch {
969+
return $multi("err", "err");
970+
}
971+
}
972+
973+
let result: string[] = [];
974+
fn().then(v => { const [a, b] = v; result = [a, b]; });
975+
976+
return result;
977+
`
978+
.withLanguageExtensions()
979+
.expectToEqual(["foo", "bar"]);
980+
});
981+
961982
// https://github.com/TypeScriptToLua/TypeScriptToLua/issues/1706
962983
test("return inside try with finally (#1706)", () => {
963984
util.testFunction`

0 commit comments

Comments
 (0)