aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStuart Sierra <mail@stuartsierra.com>2009-06-23 12:08:40 -0400
committerStuart Sierra <mail@stuartsierra.com>2009-06-23 12:08:40 -0400
commit324167ff7bc016f6da542cabf7dc43655b9b4638 (patch)
tree9463d448209b0b2291349eb371e6e51bde9e9d71
parent3073f0dc0614cb8c95f2debd0b7e6a75c1736ece (diff)
test_contrib/walk.clj: tests for c.c.walk
-rw-r--r--src/clojure/contrib/test_contrib/walk.clj34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/clojure/contrib/test_contrib/walk.clj b/src/clojure/contrib/test_contrib/walk.clj
new file mode 100644
index 00000000..a59b2279
--- /dev/null
+++ b/src/clojure/contrib/test_contrib/walk.clj
@@ -0,0 +1,34 @@
+(ns clojure.contrib.test-contrib.walk
+ (:require [clojure.contrib.walk :as w])
+ (:use clojure.contrib.test-is))
+
+(deftest t-prewalk-replace
+ (is (= (w/prewalk-replace {:a :b} [:a {:a :a} (list 3 :c :a)])
+ [:b {:b :b} (list 3 :c :b)])))
+
+(deftest t-postwalk-replace
+ (is (= (w/postwalk-replace {:a :b} [:a {:a :a} (list 3 :c :a)])
+ [:b {:b :b} (list 3 :c :b)])))
+
+(deftest t-stringify-keys
+ (is (= (w/stringify-keys {:a 1, nil {:b 2 :c 3}, :d 4})
+ {"a" 1, nil {"b" 2 "c" 3}, "d" 4})))
+
+(deftest t-prewalk-order
+ (is (= (let [a (atom [])]
+ (w/prewalk (fn [form] (swap! a conj form) form)
+ [1 2 {:a 3} (list 4 [5])])
+ @a)
+ [[1 2 {:a 3} (list 4 [5])]
+ 1 2 {:a 3} [:a 3] :a 3 (list 4 [5])
+ 4 [5] 5])))
+
+(deftest t-postwalk-order
+ (is (= (let [a (atom [])]
+ (w/postwalk (fn [form] (swap! a conj form) form)
+ [1 2 {:a 3} (list 4 [5])])
+ @a)
+ [1 2
+ {} :a 3 [:a 3] {:a 3}
+ 4 5 [5] (list 4 [5])
+ [1 2 {:a 3} (list 4 [5])]]))) \ No newline at end of file