在下面的代码中,我想在实现 bar 函数之前测试 foo 函数。
(unfinished bar)
(def tbl {:ev1 bar})
(defn foo [ev] ((tbl ev)))
(fact "about an indirect call"
(foo :ev1) => nil
(provided
(bar) => nil))
但米杰说:
FAIL at (core_test.clj:86)
These calls were not made the right number of times:
(bar) [expected at least once, actually never called]
FAIL "about an indirect call" at (core_test.clj:84)
Expected: nil
Actual: java.lang.Error: #'bar has no implementation,
but it was called like this:
(bar )
我认为“提供”不能挂钩 bar 函数,因为 foo 没有直接调用 bar。但我也发现如果我像这样更改第二行:
(def tbl {:ev1 #(bar)})
然后测试成功了。
第一个版本有什么方法可以成功吗?
谢谢。
PS:我正在使用 Clojure 1.5.1 和 Midje 1.5.1。