From 3fee82f050e055ba7770a2b0135f2ebe4ee7b985 Mon Sep 17 00:00:00 2001 From: Andrey Listopadov Date: Mon, 10 May 2021 18:33:15 +0000 Subject: Try multi value return --- tests/macros.fnl | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'tests/macros.fnl') 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)))))) -- cgit v1.2.3