mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:17:44 +00:00
LibJS: Allow try statement with only finally clause
This was a regression introduced by 9ffe45b - a TryStatement without 'catch' clause *is* allowed, if it has a 'finally' clause. It is now checked properly that at least one of both is present.
This commit is contained in:
parent
aa115fe27b
commit
d6f8c52245
2 changed files with 16 additions and 1 deletions
|
@ -161,3 +161,12 @@ test("try/catch/finally with exception in try, catch and finally", () => {
|
|||
expect(catchHasBeenExecuted).toBeTrue();
|
||||
expect(finallyHasBeenExecuted).toBeTrue();
|
||||
});
|
||||
|
||||
test("try statement must have either 'catch' or 'finally' clause", () => {
|
||||
expect("try {} catch {}").toEval();
|
||||
expect("try {} catch (e) {}").toEval();
|
||||
expect("try {} finally {}").toEval();
|
||||
expect("try {} catch {} finally {}").toEval();
|
||||
expect("try {} catch (e) {} finally {}").toEval();
|
||||
expect("try {}").not.toEval();
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue