Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions test/clojure/core_test/compare.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,23 @@
;; zero? ['() '()]
)

;; Phel's `compare` treats vectors, lists, sets, maps, and ranges as
;; comparable collections (comparing element-wise / by count) rather than
;; throwing like Clojure does for non-`Comparable` types. Comparing a
;; collection against a different collection *kind* (e.g. vector vs map)
;; still throws. Documented divergence.
;; Phel's `compare` treats vectors, lists and every other sequential seq
;; (ranges, lazy seqs) as comparable, element-wise, rather than throwing
;; like Clojure does for non-`Comparable` types. Two sets or two maps
;; compare 0 when equal and throw otherwise, as in Clojure. A collection
;; against a different kind (e.g. vector vs map) still throws.
;; Documented divergence.
#?(:phel (do
(is (zero? (compare [] '())))
(is (p/thrown? (compare [1] [[]])))
(is (p/thrown? (compare [] {})))
(is (p/thrown? (compare [] #{})))
(is (zero? (compare #{1} #{1})))
(is (zero? (compare {1 2} {1 2})))
(is (pos? (compare (range 5) (range 5)))))
(is (p/thrown? (compare #{1} #{2})))
(is (p/thrown? (compare {1 2} {1 3})))
(is (zero? (compare (range 5) (range 5))))
(is (neg? (compare (range 4) (range 5)))))
:default
(do
(is (p/thrown? (compare [] '())))
Expand Down
Loading