我执行了以下代码(从真实用例中提取),并期望得到“Fake 2 a b”:
(defn real-func
([a] (real-func a "S"))
([a b] (real-func a b "S"))
([a b c] (println "Real " a b c)))
(defn fake-func
([a b] (println "Fake 2" a b)))
(deftest blah-test
(testing "blah blah"
(with-redefs [real-func fake-func] (real-func "a" "b"))))
但相反,我得到一个错误:
#object[TypeError TypeError: videra_web.effects.graphql_test.real_func.cljs$core$IFn$_invoke$arity$2 is not a function]
奇怪的是,如果我添加另一个 arity(任何 arity)fake-func
它可以工作:例如
(defn fake-func
([a b] (println "Fake 2" a b))
([a b c d e] (println "Fake 5" a b c d e))
)
这看起来像是一个错误,还是有我不理解的语言功能?