diff options
| author | Andrey Listopadov <andreyorst@gmail.com> | 2021-05-10 18:33:17 +0000 |
|---|---|---|
| committer | Andrey Listopadov <andreyorst@gmail.com> | 2021-05-10 18:33:17 +0000 |
| commit | 9ff783f512674e60add2ce71bd20745ff446f57f (patch) | |
| tree | ca9d6e464aff19fdf6141c21f6b87e5054aa76d3 /tests/macros.fnl | |
| parent | 9ff8b7069da390540168723ce110b92f6d17c6b0 (diff) | |
| parent | 3fee82f050e055ba7770a2b0135f2ebe4ee7b985 (diff) | |
Merge branch 'try-multi-value-return' into 'master'
Try multi value return
Closes #2
See merge request andreyorst/fennel-cljlib!10
Diffstat (limited to 'tests/macros.fnl')
| -rw-r--r-- | tests/macros.fnl | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/tests/macros.fnl b/tests/macros.fnl index ec8aebd..2176f15 100644 --- a/tests/macros.fnl +++ b/tests/macros.fnl @@ -210,6 +210,7 @@ (assert-eq (try (+ 1 2 3) (catch _ 0) (finally 10)) 6) (assert-eq (try (+ 1 2 3 nil) (catch _ 0) (finally 10)) 0) (assert-eq (try (+ 1 2 3 nil) (catch _) (finally 10)) nil)) + (testing "catch-all" (assert-eq (try (error "10") @@ -219,6 +220,7 @@ (error [10]) (catch err err)) [10])) + (testing "finally" (let [tbl []] (try @@ -234,4 +236,14 @@ (catch _ (table.insert tbl 5)) (catch 20 (table.insert tbl 6)) (finally (table.insert tbl 7))) - (assert-eq tbl [1 2 3 4 5 7])))) + (assert-eq tbl [1 2 3 4 5 7]))) + + (testing "runtime error" + (assert-eq 0 (try + (/ 1 nil) + (catch _ 0)))) + + (testing "multi-value results" + (assert-eq 3 (select :# (try (values 1 2 3)))) + (assert-eq [1 2 3] [(try (values 1 2 3))]) + (assert-eq 6 (select :# (try (values 1 nil 3 nil nil nil)))))) |