Skip to content

Commit 409fcc9

Browse files
ejloDavid Nolen
authored andcommitted
Bugfix PersistentTreeSet lookup
1 parent ddcb192 commit 409fcc9

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/cljs/cljs/core.cljs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5743,9 +5743,10 @@ reduces them without incurring seq initialization"
57435743
(-lookup [coll v]
57445744
(-lookup coll v nil))
57455745
(-lookup [coll v not-found]
5746-
(if (-contains-key? tree-map v)
5747-
v
5748-
not-found))
5746+
(let [n (.entry-at tree-map v)]
5747+
(if-not (nil? n)
5748+
(.-key n)
5749+
not-found)))
57495750

57505751
ISet
57515752
(-disjoin [coll v]

test/cljs/cljs/core_test.cljs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,15 +1260,18 @@
12601260
;; PersistentTreeSet
12611261
(let [s1 (sorted-set)
12621262
c2 (comp - compare)
1263-
s2 (sorted-set-by c2)]
1263+
s2 (sorted-set-by c2)
1264+
c3 #(compare (quot %1 2) (quot %2 2))
1265+
s3 (sorted-set-by c3)]
12641266
(assert (identical? cljs.core.PersistentTreeSet (type s1)))
12651267
(assert (identical? cljs.core.PersistentTreeSet (type s2)))
12661268
(assert (identical? compare (-comparator s1)))
12671269
(assert (identical? c2 (-comparator s2)))
12681270
(assert (zero? (count s1)))
12691271
(assert (zero? (count s2)))
12701272
(let [s1 (conj s1 1 2 3)
1271-
s2 (conj s2 1 2 3)]
1273+
s2 (conj s2 1 2 3)
1274+
s3 (conj s3 1 2 3)]
12721275
(assert (= (hash s1) (hash s2)))
12731276
(assert (= (hash s1) (hash #{1 2 3})))
12741277
(assert (= (seq s1) (list 1 2 3)))
@@ -1277,6 +1280,8 @@
12771280
(assert (= (rseq s2) (list 1 2 3)))
12781281
(assert (= (count s1) 3))
12791282
(assert (= (count s2) 3))
1283+
(assert (= (count s3) 2))
1284+
(assert (= (get s3 0) 1))
12801285
(let [s1 (disj s1 2)
12811286
s2 (disj s2 2)]
12821287
(assert (= (seq s1) (list 1 3)))

0 commit comments

Comments
 (0)