在尝试使用规范库时,我在尝试使用 exercise-fn 时遇到错误。我已将其简化为主要指南页面上发布的示例,没有任何变化。
相关代码:
(ns spec1
(:require [clojure.spec.alpha :as s]))
;;this and the fdef are literal copies from the example page
(defn adder [x] #(+ x %))
(s/fdef adder
:args (s/cat :x number?)
:ret (s/fspec :args (s/cat :y number?)
:ret number?)
:fn #(= (-> % :args :x) ((:ret %) 0)))
现在,输入以下内容
(s/exercise-fn adder)
给出错误:
Exception No :args spec found, can't generate clojure.spec.alpha/exercise-fn (alpha.clj:1833)
使用的依赖项/版本,[org.clojure/clojure "1.9.0-beta3"] [org.clojure/tools.logging "0.4.0"] [org.clojure/test.check "0.9.0"]
任何人都知道为什么这会破坏?谢谢。