diff options
-rw-r--r-- | src/clojure/contrib/mock.clj | 13 | ||||
-rw-r--r-- | src/clojure/contrib/mock/test_adapter.clj | 1 | ||||
-rw-r--r-- | src/clojure/contrib/test_contrib/mock_test.clj | 10 | ||||
-rw-r--r-- | src/clojure/contrib/test_contrib/mock_test/test_adapter_test.clj | 4 |
4 files changed, 18 insertions, 10 deletions
diff --git a/src/clojure/contrib/mock.clj b/src/clojure/contrib/mock.clj index e079719d..a284b527 100644 --- a/src/clojure/contrib/mock.clj +++ b/src/clojure/contrib/mock.clj @@ -62,21 +62,28 @@ ;; the test framework of your choice, or to simply customize error handling.
(defn report-problem
+ {:dynamic true}
([function expected actual]
(report-problem function expected actual "Expectation not met."))
([function expected actual message]
(prn (str message " Function name: " function
" expected: " expected " actual: " actual))))
-(defn no-matching-function-signature [function expected actual]
+(defn no-matching-function-signature
+ {:dynamic true}
+ [function expected actual]
(report-problem function expected actual
"No matching real function signature for given argument count."))
-(defn unexpected-args [function expected actual i]
+(defn unexpected-args
+ {:dynamic true}
+ [function expected actual i]
(report-problem function expected actual
(str "Argument " i " has an unexpected value for function.")))
-(defn incorrect-invocation-count [function expected actual]
+(defn incorrect-invocation-count
+ {:dynamic true}
+ [function expected actual]
(report-problem function expected actual "Unexpected invocation count."))
diff --git a/src/clojure/contrib/mock/test_adapter.clj b/src/clojure/contrib/mock/test_adapter.clj index b5aa4340..466cb537 100644 --- a/src/clojure/contrib/mock/test_adapter.clj +++ b/src/clojure/contrib/mock/test_adapter.clj @@ -20,6 +20,7 @@ "This function is designed to be used in a binding macro to override the report-problem function in clojure.contrib.mock. Instead of printing the error to the console, the error is logged via clojure.test." + {:dynamic true} [fn-name expected actual msg] (report {:type :fail, :message (str msg " Function name: " fn-name), diff --git a/src/clojure/contrib/test_contrib/mock_test.clj b/src/clojure/contrib/test_contrib/mock_test.clj index d7fc9854..1737305e 100644 --- a/src/clojure/contrib/test_contrib/mock_test.clj +++ b/src/clojure/contrib/test_contrib/mock_test.clj @@ -3,14 +3,14 @@ (:require [clojure.contrib.mock :as mock])) ; Used as dummy dependency functions -(defn fn1 [x] :ignore) -(defn fn2 [x y] :ignore) -(defn fn3 ([x] :ignore) +(defn fn1 {:dynamic true} [x] :ignore) +(defn fn2 {:dynamic true} [x y] :ignore) +(defn fn3 {:dynamic true} ([x] :ignore) ([x y z] :ignore)) -(defn fn4 [x y & r] :ignore) +(defn fn4 {:dynamic true} [x y & r] :ignore) ;functions created using fn directly lack the argslist meta data -(def deffed-differently (fn [x] :ignore)) +(def #^{:dynamic true} deffed-differently (fn [x] :ignore)) (defmacro assert-called [fn-name called? & body] `(let [called-status?# (atom false)] diff --git a/src/clojure/contrib/test_contrib/mock_test/test_adapter_test.clj b/src/clojure/contrib/test_contrib/mock_test/test_adapter_test.clj index 5dc3a43d..5f21ce11 100644 --- a/src/clojure/contrib/test_contrib/mock_test/test_adapter_test.clj +++ b/src/clojure/contrib/test_contrib/mock_test/test_adapter_test.clj @@ -4,8 +4,8 @@ clojure.test)) (deftest test-report-problem-called - (def #^{:private true} fn1 (fn [x] "dummy code")) - (def #^{:private true} fn2 (fn [x y] "dummy code2")) + (def #^{:private true :dynamic true} fn1 (fn [x] "dummy code")) + (def #^{:private true :dynamic true} fn2 (fn [x y] "dummy code2")) (let [under-test (fn [x] (fn1 x))] (assert-called clojure.contrib.mock.test-adapter/report-problem true (expect [fn1 (times 5)] (under-test "hi"))))) |