mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 00:50:22 +00:00
46 lines
870 B
JavaScript
46 lines
870 B
JavaScript
test("return from try block", () => {
|
|
function foo() {
|
|
try {
|
|
return "foo";
|
|
} catch {
|
|
return "bar";
|
|
}
|
|
}
|
|
expect(foo()).toBe("foo");
|
|
});
|
|
|
|
test("return from catch block", () => {
|
|
function foo() {
|
|
try {
|
|
throw "foo";
|
|
} catch {
|
|
return "bar";
|
|
}
|
|
}
|
|
expect(foo()).toBe("bar");
|
|
});
|
|
|
|
test("return from finally block", () => {
|
|
function foo() {
|
|
try {
|
|
return "foo";
|
|
} catch {
|
|
return "bar";
|
|
} finally {
|
|
return "baz";
|
|
}
|
|
}
|
|
expect(foo()).toBe("baz");
|
|
});
|
|
|
|
test("return from catch block with empty finally", () => {
|
|
function foo() {
|
|
try {
|
|
throw "foo";
|
|
} catch {
|
|
return "bar";
|
|
} finally {
|
|
}
|
|
}
|
|
expect(foo()).toBe("bar");
|
|
});
|