Using clojure.spec (org.clojure/clojurescript {:mvn/version "1.10.520"}
), I have a function spec that specifies a map for its input.
gen/generate
and gen/sample
work fine. But calling cljs.spec.test.alpha/check
errors with input that should be a map, but is passed a collection (Error: More than one element found in structure
). Ie, it looks like the spec system is generating bad input.
Is this a bug with spec?
bar spec
(s/def ::check-run
(s/keys
:req-un
[::action
::check_run
::installation
::organization
::repository
::sender]))
foo.cljs
(s/def ::payload :bar/check-run)
(s/def ::check-run-started (s/keys :req-un [::payload]))
(s/fdef check-run->cijob-created
:args (s/cat :arg ::check-run-started))
(defn check-run->cijob-created [arg])
While the function spec only declares A, the spec system is generating B.
;; A
{:payload {:action "", :check_run {:html_url "", }}, ...}
;; B
[({:payload {:action "", :check_run {:html_url "", }}, ...}})]
workbench
(cljs.spec.test.alpha/check
`foo/check-run->cijob-created
{:clojure.spec.test.check/opts {:num-tests 10}})
[{:spec #object[cljs.spec.alpha.t_cljs$spec$alpha50916],
:clojure.spec.test.check/ret
{:shrunk
{:total-nodes-visited 313, :depth 148, :pass? false, :result #object[Error Error: More than one element found in structure: 0], :result-data #:clojure.test.check.properties{:error #object[Error Error: More than one element found in structure: 0]}, :time-shrinking-ms 11299,
:smallest
[({:payload {:action "", :check_run {:html_url "", }}, ...}})]},
:sym foo/check-run->cijob-created,
:failure #object[Error Error: More than one element found in structure: 0]}]
[1]: https://clojure.org/about/spec
Aucun commentaire:
Enregistrer un commentaire