Permalink
Browse files

fixes to make reduce work in clojure 1.4

  • Loading branch information...
1 parent e8d05ed commit d712544b6fa063cd1cfd4467fbf2d5c481656308 @vgeshel vgeshel committed Apr 23, 2012
Showing with 18 additions and 1 deletion.
  1. +9 −0 src/potemkin/map.clj
  2. +9 −1 test/potemkin/test/map.clj
View
9 src/potemkin/map.clj
@@ -74,6 +74,15 @@
(seq [this]
(map #(MapEntry. % (.valAt this % nil)) (potemkin.protocols/keys* this ~unwrapped-data)))
+ clojure.core.protocols.CollReduce
+ (coll-reduce
+ [this f]
+ (reduce f (seq this)))
+
+ (coll-reduce
+ [this f val#]
+ (reduce f val# (seq this)))
+
Object
(hashCode [this]
(reduce
View
10 test/potemkin/test/map.clj
@@ -53,7 +53,15 @@
(is (= [[:a 1]] s)))
(let [m (conj m [:a 1])]
- (is (= {:a 1} m))))
+ (is (= {:a 1} m)))
+
+ (let [m (-> m (assoc :a 1) (assoc :b 2))
+ s (reduce
+ (fn [s [k v]]
+ (+ s v))
+ 0
+ m)]
+ (is (= 3 s))))
(deftest test-maps
(test-basic-map-functionality (SimpleMap. {}))

0 comments on commit d712544

Please sign in to comment.