Skip to content

Commit

Permalink
Bugfix PersistentTreeSet lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
ejlo authored and David Nolen committed Oct 16, 2012
1 parent ddcb192 commit 409fcc9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/cljs/cljs/core.cljs
Expand Up @@ -5743,9 +5743,10 @@ reduces them without incurring seq initialization"
(-lookup [coll v]
(-lookup coll v nil))
(-lookup [coll v not-found]
(if (-contains-key? tree-map v)
v
not-found))
(let [n (.entry-at tree-map v)]
(if-not (nil? n)
(.-key n)
not-found)))

ISet
(-disjoin [coll v]
Expand Down
9 changes: 7 additions & 2 deletions test/cljs/cljs/core_test.cljs
Expand Up @@ -1260,15 +1260,18 @@
;; PersistentTreeSet
(let [s1 (sorted-set)
c2 (comp - compare)
s2 (sorted-set-by c2)]
s2 (sorted-set-by c2)
c3 #(compare (quot %1 2) (quot %2 2))
s3 (sorted-set-by c3)]
(assert (identical? cljs.core.PersistentTreeSet (type s1)))
(assert (identical? cljs.core.PersistentTreeSet (type s2)))
(assert (identical? compare (-comparator s1)))
(assert (identical? c2 (-comparator s2)))
(assert (zero? (count s1)))
(assert (zero? (count s2)))
(let [s1 (conj s1 1 2 3)
s2 (conj s2 1 2 3)]
s2 (conj s2 1 2 3)
s3 (conj s3 1 2 3)]
(assert (= (hash s1) (hash s2)))
(assert (= (hash s1) (hash #{1 2 3})))
(assert (= (seq s1) (list 1 2 3)))
Expand All @@ -1277,6 +1280,8 @@
(assert (= (rseq s2) (list 1 2 3)))
(assert (= (count s1) 3))
(assert (= (count s2) 3))
(assert (= (count s3) 2))
(assert (= (get s3 0) 1))
(let [s1 (disj s1 2)
s2 (disj s2 2)]
(assert (= (seq s1) (list 1 3)))
Expand Down

0 comments on commit 409fcc9

Please sign in to comment.