你好,我们的代码库自从引入 extend-with-metadata
协议以来就开始使用它 - 我们更喜欢映射组件而不是记录。
然而,代码库和团队都是 Clojure Spec 的大用户,我们原本预期以下语句.should 抛出异常:
(ns defproto-spec.test
(:require [clojure.spec.alpha :as s]
[clojure.spec.test.alpha :as st]))
(defprotocol SpecTest
:extend-via-metadata true
(delete [impl id]))
(s/fdef delete-impl
:args (s/cat :impl any? :id string?))
(defn delete-impl [_ id]
(println (str "This deletes " id))
id)
(def impl (with-meta {} {`delete delete-impl}))
(st/instrument)
(delete impl 1) ;; should throw but it doesn't
为什么我们期待它能正常工作呢?
也许是因为这个特性较新(1.10)以及以下原因:
defproto-spec.test> (st/instrument)
[defproto-spec.test/delete-me defproto-spec.test/delete-impl]
不幸的是,情况并非如此。如果这一功能还没有在别人的流程中,我愿意修复这个问题并记录下来。
谢谢,
Andrea.