summaryrefslogtreecommitdiff
path: root/Libraries/LibJS/Tests
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2020-10-23 20:54:00 +0100
committerAndreas Kling <kling@serenityos.org>2020-10-24 16:34:01 +0200
commitd6f8c52245abb173c176036ff0e4d79f57510b41 (patch)
tree780f595a6216981f6ec3edeb04fe9071be420f0c /Libraries/LibJS/Tests
parentaa115fe27ba330525b47bae01852b6d8ab0375c3 (diff)
downloadserenity-d6f8c52245abb173c176036ff0e4d79f57510b41.zip
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.
Diffstat (limited to 'Libraries/LibJS/Tests')
-rw-r--r--Libraries/LibJS/Tests/try-catch-finally.js9
1 files changed, 9 insertions, 0 deletions
diff --git a/Libraries/LibJS/Tests/try-catch-finally.js b/Libraries/LibJS/Tests/try-catch-finally.js
index 7aca91c500..1ff0104734 100644
--- a/Libraries/LibJS/Tests/try-catch-finally.js
+++ b/Libraries/LibJS/Tests/try-catch-finally.js
@@ -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();
+});