Make monger.internal.fn/expand-all-with more flexible

This commit is contained in:
Michael S. Klishin 2012-03-06 19:44:23 +04:00
parent 9b9005448b
commit 5a2ab1a22b
2 changed files with 3 additions and 3 deletions

View file

@ -66,7 +66,7 @@
;; clojure.lang.AFn subclasses. MK. ;; clojure.lang.AFn subclasses. MK.
clojure.lang.AFunction clojure.lang.AFunction
(expand-all [f] (f)) (expand-all [f] (f))
(expand-all-with [f expander] (expander (f))) (expand-all-with [f expander] (expander f))
Object Object
(expand-all [x] x) (expand-all [x] x)

View file

@ -38,8 +38,8 @@
})) }))
(deftest test-expand-all-with (deftest test-expand-all-with
(let [expander-fn (fn [v] (let [expander-fn (fn [f]
(* 3 v))] (* 3 (f)))]
(are [i o] (is (= (expand-all-with i expander-fn) o)) (are [i o] (is (= (expand-all-with i expander-fn) o))
{ :a 1 :int (fn [] 3) } { :a 1 :int 9 } { :a 1 :int (fn [] 3) } { :a 1 :int 9 }
{ :v [(fn [] 1) (fn [] 11)] :m { :inner (fn [] 3) } :s "Clojure" } { :v [3 33] :m { :inner 9 } :s "Clojure" }))) { :v [(fn [] 1) (fn [] 11)] :m { :inner (fn [] 3) } :s "Clojure" } { :v [3 33] :m { :inner 9 } :s "Clojure" })))