LibJS: Handle return value in switch statement unwinding

Fixes #3790.
This commit is contained in:
Linus Groh 2020-10-18 17:44:55 +01:00 committed by Andreas Kling
commit 8f54edb7a0
Notes: sideshowbarker 2024-07-19 01:51:26 +09:00
2 changed files with 22 additions and 4 deletions

View file

@ -36,4 +36,17 @@ describe("basic switch tests", () => {
expect().fail();
});
test("return from switch statement", () => {
function foo(value) {
switch (value) {
case 42:
return "return from 'case 42'";
default:
return "return from 'default'";
}
}
expect(foo(42)).toBe("return from 'case 42'");
expect(foo(43)).toBe("return from 'default'");
});
});