summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStuart Halloway <stu@thinkrelevance.com>2010-11-01 09:38:43 -0400
committerStuart Halloway <stu@thinkrelevance.com>2010-11-05 08:41:44 -0700
commit0898ad3ea4e4f051ae03c9e6a87a8cda3f9fa3de (patch)
treea621f6529d1f49f5090b346b2edc90cb885225e7
parent178d8c42609d899208e745b76b89297c4287c078 (diff)
CLJ-665 test improvements: don't touch a core var, and verify that value is put back correctly
Signed-off-by: Stuart Halloway <stu@thinkrelevance.com>
-rw-r--r--test/clojure/test_clojure/vars.clj20
1 files changed, 11 insertions, 9 deletions
diff --git a/test/clojure/test_clojure/vars.clj b/test/clojure/test_clojure/vars.clj
index 26e43ad9..82126576 100644
--- a/test/clojure/test_clojure/vars.clj
+++ b/test/clojure/test_clojure/vars.clj
@@ -62,28 +62,30 @@
; doc find-doc test
+(def stub-me :original)
+
(deftest test-with-redefs-fn
(let [p (promise)]
- (with-redefs-fn {#'nil? :temp}
+ (with-redefs-fn {#'stub-me :temp}
(fn []
- (.start (Thread. #(deliver p nil?)))
+ (.start (Thread. #(deliver p stub-me)))
@p))
(is (= :temp @p))
- (is (not= @p nil?))))
+ (is (= :original stub-me))))
(deftest test-with-redefs
(let [p (promise)]
- (with-redefs [nil? :temp]
- (.start (Thread. #(deliver p nil?)))
+ (with-redefs [stub-me :temp]
+ (.start (Thread. #(deliver p stub-me)))
@p)
(is (= :temp @p))
- (is (not= @p nil?))))
+ (is (= :original stub-me))))
(deftest test-with-redefs-throw
(let [p (promise)]
(is (thrown? Exception
- (with-redefs [nil? :temp]
- (deliver p nil?)
+ (with-redefs [stub-me :temp]
+ (deliver p stub-me)
(throw (Exception. "simulated failure in with-redefs")))))
(is (= :temp @p))
- (is (not= @p nil?))))
+ (is (= :original stub-me))))