aboutsummaryrefslogtreecommitdiff
path: root/src/clojure/contrib/test_contrib
diff options
context:
space:
mode:
Diffstat (limited to 'src/clojure/contrib/test_contrib')
-rw-r--r--src/clojure/contrib/test_contrib/fnmap.clj6
-rw-r--r--src/clojure/contrib/test_contrib/monads.clj6
-rw-r--r--src/clojure/contrib/test_contrib/pprint/helper.clj2
-rw-r--r--src/clojure/contrib/test_contrib/shell_out.clj10
-rw-r--r--src/clojure/contrib/test_contrib/walk.clj34
5 files changed, 46 insertions, 12 deletions
diff --git a/src/clojure/contrib/test_contrib/fnmap.clj b/src/clojure/contrib/test_contrib/fnmap.clj
index ccd7a54a..8d833360 100644
--- a/src/clojure/contrib/test_contrib/fnmap.clj
+++ b/src/clojure/contrib/test_contrib/fnmap.clj
@@ -4,16 +4,16 @@
(deftest acts-like-map
(let [m1 (fnmap get assoc :key1 1 :key2 2)]
- (are (= _2 (get m1 _1))
+ (are [k v] (= v (get m1 k))
:key1 1
:key2 2
:nonexistent-key nil)
- (are (= _2 (_1 m1))
+ (are [k v] (= v (k m1))
:key1 1
:key2 2
:nonexistent-key nil)
(let [m2 (assoc m1 :key3 3 :key4 4)]
- (are (= _2 (get m2 _1))
+ (are [k v] (= v (get m2 k))
:key1 1
:key2 2
:key3 3
diff --git a/src/clojure/contrib/test_contrib/monads.clj b/src/clojure/contrib/test_contrib/monads.clj
index 5d38b544..a09d646d 100644
--- a/src/clojure/contrib/test_contrib/monads.clj
+++ b/src/clojure/contrib/test_contrib/monads.clj
@@ -19,7 +19,7 @@
(deftest sequence-monad
(with-monad sequence-m
- (are (= _1 _2)
+ (are [a b] (= a b)
(domonad [x (range 3) y (range 2)] (+ x y))
'(0 1 1 2 2 3)
(domonad [x (range 5) y (range (+ 1 x)) :when (= (+ x y) 2)] (list x y))
@@ -37,7 +37,7 @@
(with-monad maybe-m
(let [m+ (m-lift 2 +)
mdiv (fn [x y] (domonad [a x b y :when (not (zero? b))] (/ a b)))]
- (are (= _1 _2)
+ (are [a b] (= a b)
(m+ (m-result 1) (m-result 3))
(m-result 4)
(mdiv (m-result 1) (m-result 3))
@@ -50,7 +50,7 @@
(deftest seq-maybe-monad
(with-monad (maybe-t sequence-m)
(letfn [(pairs [xs] ((m-lift 2 #(list %1 %2)) xs xs))]
- (are (= _1 _2)
+ (are [a b] (= a b)
((m-lift 1 inc) (for [n (range 10)] (when (odd? n) n)))
'(nil 2 nil 4 nil 6 nil 8 nil 10)
(pairs (for [n (range 5)] (when (odd? n) n)))
diff --git a/src/clojure/contrib/test_contrib/pprint/helper.clj b/src/clojure/contrib/test_contrib/pprint/helper.clj
index c7112e68..9a4005d6 100644
--- a/src/clojure/contrib/test_contrib/pprint/helper.clj
+++ b/src/clojure/contrib/test_contrib/pprint/helper.clj
@@ -17,5 +17,5 @@
(:use [clojure.contrib.test-is :only (deftest are run-tests)]))
(defmacro simple-tests [name & test-pairs]
- `(deftest ~name (are (= _1 _2) ~@test-pairs)))
+ `(deftest ~name (are [x y] (= x y) ~@test-pairs)))
diff --git a/src/clojure/contrib/test_contrib/shell_out.clj b/src/clojure/contrib/test_contrib/shell_out.clj
index 0bd1afbe..b6cedabb 100644
--- a/src/clojure/contrib/test_contrib/shell_out.clj
+++ b/src/clojure/contrib/test_contrib/shell_out.clj
@@ -9,7 +9,7 @@
(def as-env-string ((ns-interns 'clojure.contrib.shell-out) 'as-env-string))
(deftest test-parse-args
- (are (= _1 _2)
+ (are [x y] (= x y)
{:cmd [nil] :out "UTF-8" :dir nil :env nil} (parse-args [])
{:cmd ["ls"] :out "UTF-8" :dir nil :env nil} (parse-args ["ls"])
{:cmd ["ls" "-l"] :out "UTF-8" :dir nil :env nil} (parse-args ["ls" "-l"])
@@ -17,17 +17,17 @@
))
(deftest test-with-sh-dir
- (are (= _1 _2)
+ (are [x y] (= x y)
nil *sh-dir*
"foo" (with-sh-dir "foo" *sh-dir*)))
(deftest test-with-sh-env
- (are (= _1 _2)
+ (are [x y] (= x y)
nil *sh-env*
{:KEY "VAL"} (with-sh-env {:KEY "VAL"} *sh-env*)))
(deftest test-as-env-string
- (are (= _1 _2)
+ (are [x y] (= x y)
nil (as-env-string nil)
["FOO=BAR"] (seq (as-env-string {"FOO" "BAR"}))
["FOO_SYMBOL=BAR"] (seq (as-env-string {'FOO_SYMBOL "BAR"}))
@@ -35,7 +35,7 @@
(deftest test-as-file
- (are (= _1 _2)
+ (are [x y] (= x y)
(File. "foo") (as-file "foo")
nil (as-file nil)
(File. "bar") (as-file (File. "bar")))) \ No newline at end of file
diff --git a/src/clojure/contrib/test_contrib/walk.clj b/src/clojure/contrib/test_contrib/walk.clj
new file mode 100644
index 00000000..2fb36d4e
--- /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