你好,我到这里来报告我认为是我一周内第二次出现的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
我是做错了什么吗?