From 844c3eb20293795b675cb013481b46f28c434a37 Mon Sep 17 00:00:00 2001 From: rafonsecad Date: Tue, 21 Oct 2025 22:23:00 -0500 Subject: [PATCH] test rseq --- test/clojure/core_test/rseq.cljc | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 test/clojure/core_test/rseq.cljc diff --git a/test/clojure/core_test/rseq.cljc b/test/clojure/core_test/rseq.cljc new file mode 100644 index 0000000..6f77d9b --- /dev/null +++ b/test/clojure/core_test/rseq.cljc @@ -0,0 +1,29 @@ +(ns clojure.core-test.rseq + (:require [clojure.test :as t :refer [deftest testing is are]] + [clojure.core-test.portability #?(:cljs :refer-macros :default :refer) [when-var-exists]])) + +(when-var-exists rseq + (deftest test-rseq + (testing "common" + (is (= nil (rseq []))) + (is (= '(3 2 1) (rseq [1 2 3]))) + (is (= '(:c :b :a) (rseq [:a :b :c]))) + (is (= '(\c \b \a) (rseq [\a \b \c]))) + (is (= '(4 3 [1 2]) (rseq [[1 2] 3 4]))) + #?@(:cljs [(is (thrown? js/Error (rseq nil))) + (is (thrown? js/Error (rseq ""))) + (is (thrown? js/Error (rseq :a))) + (is (thrown? js/Error (rseq 0))) + (is (thrown? js/Error (rseq 0.0))) + (is (thrown? js/Error (rseq {:a :b})))] + :default [(is (thrown? Exception (rseq nil))) + (is (thrown? Exception (rseq ""))) + (is (thrown? Exception (rseq \space))) + (is (thrown? Exception (rseq :a))) + (is (thrown? Exception (rseq 0))) + (is (thrown? Exception (rseq 0.0))) + (is (thrown? Exception (rseq {:a :b})))])) + + (when-var-exists clojure.core/sorted-map + (testing "sorted-map" + (is (= '([:c 2] [:b 1] [:a 0]) (rseq (sorted-map :a 0, :b 1, :c 2))))))))