Skip to content

Commit ac6f89c

Browse files
authored
test rseq (#766)
1 parent 12e04a4 commit ac6f89c

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

test/clojure/core_test/rseq.cljc

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
(ns clojure.core-test.rseq
2+
(:require [clojure.test :as t :refer [deftest testing is are]]
3+
[clojure.core-test.portability #?(:cljs :refer-macros :default :refer) [when-var-exists]]))
4+
5+
(when-var-exists rseq
6+
(deftest test-rseq
7+
(testing "common"
8+
(is (= nil (rseq [])))
9+
(is (= '(3 2 1) (rseq [1 2 3])))
10+
(is (= '(:c :b :a) (rseq [:a :b :c])))
11+
(is (= '(\c \b \a) (rseq [\a \b \c])))
12+
(is (= '(4 3 [1 2]) (rseq [[1 2] 3 4])))
13+
#?@(:cljs [(is (thrown? js/Error (rseq nil)))
14+
(is (thrown? js/Error (rseq "")))
15+
(is (thrown? js/Error (rseq :a)))
16+
(is (thrown? js/Error (rseq 0)))
17+
(is (thrown? js/Error (rseq 0.0)))
18+
(is (thrown? js/Error (rseq {:a :b})))]
19+
:default [(is (thrown? Exception (rseq nil)))
20+
(is (thrown? Exception (rseq "")))
21+
(is (thrown? Exception (rseq \space)))
22+
(is (thrown? Exception (rseq :a)))
23+
(is (thrown? Exception (rseq 0)))
24+
(is (thrown? Exception (rseq 0.0)))
25+
(is (thrown? Exception (rseq {:a :b})))]))
26+
27+
(when-var-exists clojure.core/sorted-map
28+
(testing "sorted-map"
29+
(is (= '([:c 2] [:b 1] [:a 0]) (rseq (sorted-map :a 0, :b 1, :c 2))))))))

0 commit comments

Comments
 (0)