你好,自从引入以来,我们的代码库就采用了 extend-with-metadata
协议,我们更喜欢使用映射组件而不是记录。
然而,代码库和团队都是大的 Clojure spec 用户,我们原本期望以下最后一个形式会抛出异常
(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.