cljs.spec.test.alpha/check
(check)
(check sym-or-syms)
(check sym-or-syms opts)
Source docstring:
Run generative tests for spec conformance on vars named by
sym-or-syms, a symbol or collection of symbols. If sym-or-syms
is not specified, check all checkable vars. If a symbol identifies a
namespace then all symbols in that namespace will be enumerated.
The opts map includes the following optional keys, where stc
aliases clojure.spec.test.check:
::stc/opts opts to flow through test.check/quick-check
:gen map from spec names to generator overrides
The ::stc/opts include :num-tests in addition to the keys
documented by test.check. Generator overrides are passed to
spec/gen when generating function args.
Returns a lazy sequence of check result maps with the following
keys
:spec the spec tested
:sym optional symbol naming the var tested
:failure optional test failure
::stc/ret optional value returned by test.check/quick-check
The value for :failure can be any exception. Exceptions thrown by
spec itself will have an ::s/failure value in ex-data:
:check-failed at least one checked return did not conform
:no-args-spec no :args spec provided
:no-fn no fn provided
:no-fspec no fspec provided
:no-gen unable to generate :args
:instrument invalid args detected by instrument
(defmacro check
([]
`(check ^::no-eval '~(checkable-syms*)))
([sym-or-syms]
`(check ~sym-or-syms nil))
([sym-or-syms opts]
(let [syms (sym-or-syms->syms (form->sym-or-syms sym-or-syms))
opts-sym (gensym "opts")]
`(if (and (cljs.core/exists? clojure.test.check)
(cljs.core/exists? clojure.test.check.properties))
(let [~opts-sym ~opts]
[~@(->> syms
(filter (checkable-syms* opts))
(map
(fn [sym]
(do `(check-1 '~sym nil nil ~opts-sym)))))])
(throw
(js/Error. (str "Require clojure.test.check and "
"clojure.test.check.properties before calling check.")))))))