嗨,我在这里报告我认为是我在一周内遇到的第二个小问题,与 spec 仪表有关。
如果它已被报告为错误,请原谅我,但我基本上无法理解/预期的最后一个调用触发错误 - ::id-map
规格不需要对 ::other
执行检查。
(ns repro-spec.test
(:require [clojure.spec.alpha :as s]
[clojure.spec.test.alpha :as st]))
(s/def ::impl any?)
(s/def ::id string?)
(s/def ::other number?)
(s/def ::id-map (s/keys :req [::id]))
(s/fdef delete-impl
:args (s/cat :impl ::impl
:id-map ::id-map))
(defn delete-impl [_ id-map]
(println (str "This deletes " (::id id-map)))
id-map)
(st/instrument)
(delete-impl {} {::id "test"})
;; prints "This deletes test"
(delete-impl {} {::id "test" ::other "ignore me"})
;; Execution error - invalid arguments to repro-spec.test/delete-impl at (REPL:27).
;; "ignore me" - failed: number? at: [:id-map :repro-spec.test/other] spec: :repro-spec.test/other
是我做错了什么吗?