Permalink
Browse files

Bugfix PersistentTreeSet lookup

  • Loading branch information...
1 parent ddcb192 commit 409fcc9a824668207953b2bc47d40aaab85191d3 @ejlo ejlo committed with David Nolen Oct 15, 2012
Showing with 11 additions and 5 deletions.
  1. +4 −3 src/cljs/cljs/core.cljs
  2. +7 −2 test/cljs/cljs/core_test.cljs
View
@@ -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]
@@ -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)))
@@ -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)))

0 comments on commit 409fcc9

Please sign in to comment.