我正在尝试指定以下名为 Connection 的数据结构:
{:id "some string" :channel "instance of org.httpkit.server.AsyncChannel" }
这是我的规格:
(defn make-channel []
(proxy [AsyncChannel] [nil nil]
(toString [] "mock AsyncChannel")))
(defn channel-gen
[]
(->> (s/gen (s/int-in 0 1))
(gen/fmap (fn [_] (make-channel)))))
(s/def ::channel (s/spec (::channel-type)
:gen channel-gen))
(s/def ::id string?)
(s/def ::connection (s/keys :req-un [::channel ::id]))
(s/fdef make-connection
:args ::channel
:ret ::connection)
我收到以下错误,我不知道这里出了什么问题:
clojure.lang.ExceptionInfo: Unable to construct gen at: [] for: gameserve.ws$make_connection@788ffa19
clojure.lang.Compiler$CompilerException: clojure.lang.ExceptionInfo: Unable to construct gen at: [] for: gameserve.ws$make_connection@788ffa19 #:clojure.spec.alpha{:path [], :form #object[gameserve.ws$make_connection 0x788ffa19 "gameserve.ws$make_connection@788ffa19"], :failure :no-gen}