重现
(s/def :ex/f fn?)
(s/def :ex/m (s/keys :opt [:ex/f]))
(s/fdef my-fn
:args (s/cat :m :ex/m))
(defn my-fn [f])
(clojure.spec.test.alpha/check `my-fn)
实际:抛出异常 - "在[:m :ex/f]处无法构建gen的异常为::ex/f"
预期:应返回包含失败值的结果。如果您将keys spec中的":opt"替换为":req",则会发生这种行为。
我期望这个值包含一个失败,如下所示:
(ex-data (:result (:clojure.spec.test.check/ret (first (clojure.spec.test.alpha/check `my-fn))))) ;; => #:clojure.spec.alpha{:path [:m :ex/f], :form :ex/f, :failure :no-gen}