File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 1+ (ns clojure.core-test.seq
2+ (:require [clojure.test :as t :refer [deftest testing is are]]))
3+
4+ (deftest test-seq
5+ ; ; Sourced via canSeq https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/RT.java#L581
6+ (are [in expected] (= expected (seq in))
7+ " test" '(\t \e \s \t)
8+ [1 2 3 4 ] '(1 2 3 4 )
9+ '(:a :b :c :d ) '(:a :b :c :d )
10+ '() nil
11+ nil nil
12+ (sorted-set 3.0 1.0 -2.5 4.0 ) '(-2.5 1.0 3.0 4.0 )
13+ (range 5 10 ) '(5 6 7 8 9 )
14+ (int-array 3 ) '(0 0 0 ))
15+ (testing " sets and maps"
16+ (let [input #{440M 55000M 80000 }
17+ input-hash (into (hash-set ) input)
18+ input-map {:a {:b " 4" }
19+ :c 800
20+ nil 40 }
21+ input-sorted-map (into (sorted-map ) input-map)
22+ input-hash-map (into (hash-map ) input-map)]
23+ (is (= input (into #{} (seq input))))
24+ (is (= input-hash (into (hash-set ) (seq input))))
25+ (is (= input-sorted-map (into (sorted-map ) (seq input-sorted-map))))
26+ (is (= input-hash-map (into (hash-map ) (seq input-hash-map))))
27+ (is (= input-map (into {} (seq input-map))))))
28+ (testing " nonseqables"
29+ (is (thrown? IllegalArgumentException (seq 1 )))
30+ (is (thrown? IllegalArgumentException (seq (fn [])))))
31+ (testing " infinite sequences are produced by seq"
32+ (let [infinite-seq (seq (range ))]
33+ (is (seq? infinite-seq))
34+ (is (= (range 10000 ) (take 10000 infinite-seq))))))
You can’t perform that action at this time.
0 commit comments