Skip to content
Browse files

with-redefs saves root binding instead of thread-local

Signed-off-by: Stuart Halloway <stu@thinkrelevance.com>
  • Loading branch information...
1 parent 89245c6 commit e7ec4e17523b9f26509662a84bedc9f6a599d0e0 @gfredericks gfredericks committed with stuarthalloway Jul 10, 2012
Showing with 10 additions and 1 deletion.
  1. +1 −1 src/clj/clojure/core.clj
  2. +9 −0 test/clojure/test_clojure/vars.clj
View
2 src/clj/clojure/core.clj
@@ -6609,7 +6609,7 @@
(doseq [[a-var a-val] m]
(.bindRoot ^clojure.lang.Var a-var a-val)))
old-vals (zipmap (keys binding-map)
- (map deref (keys binding-map)))]
+ (map #(.getRawRoot %) (keys binding-map)))]
(try
(root-bind binding-map)
(func)
View
9 test/clojure/test_clojure/vars.clj
@@ -89,3 +89,12 @@
(throw (Exception. "simulated failure in with-redefs")))))
(is (= :temp @p))
(is (= :original stub-me))))
+
+(def ^:dynamic dynamic-var 1)
+
+(deftest test-with-redefs-inside-binding
+ (binding [dynamic-var 2]
+ (is (= 2 dynamic-var))
+ (with-redefs [dynamic-var 3]
+ (is (= 2 dynamic-var))))
+ (is (= 1 dynamic-var)))

0 comments on commit e7ec4e1

Please sign in to comment.
Something went wrong with that request. Please try again.