Permalink
Browse files

Add tests for sorted-map reduction problems

Signed-off-by: Stuart Halloway <stu@thinkrelevance.com>
  • Loading branch information...
1 parent 87c6f24 commit 872acfa1501ef47803edfb2d26b5f9526edc65ec @amalloy amalloy committed with stuarthalloway Aug 10, 2012
Showing with 11 additions and 0 deletions.
  1. +11 −0 test/clojure/test_clojure/reducers.clj
@@ -39,3 +39,14 @@
(defequivtest test-filter
[filter r/filter #(into [] %)]
[even? odd? #(< 200 %) identity])
+
+
+(deftest test-sorted-maps
+ (let [m (into (sorted-map)
+ '{1 a, 2 b, 3 c, 4 d})]
+ (is (= "1a2b3c4d" (reduce-kv str "" m))
+ "Sorted maps should reduce-kv in sorted order")
+ (is (= 1 (reduce-kv (fn [acc k v]
+ (reduced (+ acc k)))
+ 0 m))
+ "Sorted maps should stop reduction when asked")))

0 comments on commit 872acfa

Please sign in to comment.