重现
(require '[clojure.spec.alpha :as s])
(s/def :fspec-test/plus (s/fspec
:args (s/cat :x int? :y pos-int?)
:ret pos-int?))
(defn my-plus [x y]
(+ x y))
(s/explain-data :fspec-test/plus my-plus)
实际
;; #:clojure.spec.alpha{:problems [{:path [:ret], :pred clojure.core/pos-int?, :val 0, :via [:fspec-test/plus], :in []}], :spec :fspec-test/plus, :value #function[expound.alpha-test/my-plus]}
预期:我期望explain-data包含产生无效返回值的参数,以便我可以重现。请注意,如果我的函数抛出异常,explain数据将包含参数,例如:
(s/def :fspec-test/plus (s/fspec
:args (s/cat :x int? :y pos-int?)))
(defn my-plus [x y]
(assert (pos? (+ x y))))
(s/explain-data :fspec-test/plus my-plus)
;; #:clojure.spec.alpha{:problems [{:path [], :pred (apply fn), :val (-1 1), :reason "Assert failed: (pos? (+ x y))", :via [:fspec-test/plus], :in []}], :spec :fspec-test/plus, :value #function[expound.alpha-test/my-plus]}