From 83d542f98dbdc3ede98c505600b783b5485761d1 Mon Sep 17 00:00:00 2001 From: Pierre-Henri Trivier Date: Sat, 8 Mar 2025 11:20:26 +0100 Subject: [PATCH 1/2] Tests for default argument of nth --- test/clojure/core_test/nth.cljc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/clojure/core_test/nth.cljc b/test/clojure/core_test/nth.cljc index 38c5fd0..2e34cf1 100644 --- a/test/clojure/core_test/nth.cljc +++ b/test/clojure/core_test/nth.cljc @@ -16,4 +16,9 @@ (is (thrown? #?(:cljs :default, :clj Exception) (nth [0 1 2] -1))) (is (thrown? #?(:cljs :default, :clj Exception) (nth [0 1 2] 10))) (is (thrown? #?(:cljs :default, :clj Exception) (nth [0 1 2] nil))) - (is (thrown? #?(:cljs :default, :clj Exception) (nth nil nil))))) + (is (thrown? #?(:cljs :default, :clj Exception) (nth nil nil))) + + ;; `nth` accepts a default argument + (is (= :default (nth nil 0 :default))) + (is (= :default (nth [0] 1 :default))) + (is (= :default (nth [0 1] 2 :default))))) From 382a226e3663436608c1590d68349660b8c86845 Mon Sep 17 00:00:00 2001 From: Pierre-Henri Trivier Date: Mon, 10 Mar 2025 21:25:00 +0100 Subject: [PATCH 2/2] Add test for negative argument --- test/clojure/core_test/nth.cljc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/clojure/core_test/nth.cljc b/test/clojure/core_test/nth.cljc index 2e34cf1..9941554 100644 --- a/test/clojure/core_test/nth.cljc +++ b/test/clojure/core_test/nth.cljc @@ -21,4 +21,5 @@ ;; `nth` accepts a default argument (is (= :default (nth nil 0 :default))) (is (= :default (nth [0] 1 :default))) - (is (= :default (nth [0 1] 2 :default))))) + (is (= :default (nth [0 1] 2 :default))) + (is (= :default (nth [0 1] -1 :default)))))