Skip to content

Commit f506e88

Browse files
thomasmulvaneyswannodette
authored andcommitted
CLJS-2068: MapEntry, RedNode and BlackNode are IComparable
1 parent 55f9bcc commit f506e88

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

src/main/cljs/cljs/core.cljs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9753,6 +9753,24 @@ reduces them without incurring seq initialization"
97539753
(throw (js/Error. (str "Cannot compare " x " to " y)))))
97549754

97559755
PersistentVector
9756+
(-compare [x y]
9757+
(if (vector? y)
9758+
(compare-indexed x y)
9759+
(throw (js/Error. (str "Cannot compare " x " to " y)))))
9760+
9761+
MapEntry
9762+
(-compare [x y]
9763+
(if (vector? y)
9764+
(compare-indexed x y)
9765+
(throw (js/Error. (str "Cannot compare " x " to " y)))))
9766+
9767+
BlackNode
9768+
(-compare [x y]
9769+
(if (vector? y)
9770+
(compare-indexed x y)
9771+
(throw (js/Error. (str "Cannot compare " x " to " y)))))
9772+
9773+
RedNode
97569774
(-compare [x y]
97579775
(if (vector? y)
97589776
(compare-indexed x y)

src/test/cljs/cljs/map_entry_test.cljs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,11 @@
133133
:key (e 0 :not-found)
134134
:val (e 1 :not-found)
135135
:not-found (e 2 :not-found)
136-
:not-found (e -1 :not-found))))))
136+
:not-found (e -1 :not-found))))
137+
138+
(testing "IComparable"
139+
(testing "-compare"
140+
(is (zero? (-compare e [:key :val])))))))
137141

138142
(deftest all-map-entry-tests
139143
(testing "BlackNode"

0 commit comments

Comments
 (0)