0
在下面的代码中,我想在实现bar函数之前测试foo函数。在Clojure和Midje中,如何编写间接调用的先决条件?
(unfinished bar)
(def tbl {:ev1 bar})
(defn foo [ev] ((tbl ev)))
(fact "about an indirect call"
(foo :ev1) => nil
(provided
(bar) => nil))
但Midje说:
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)
我认为“提供”不能勾栏功能,因为富并没有直接调用了吧。但我也发现,如果我改变了这样的第二行:
(def tbl {:ev1 #(bar)})
然后测试成功。
有什么办法可以成功的第一个版本?
谢谢。 PS:我使用的是Clojure 1.5.1和Midje 1.5.1。