cljs.spec/fspec
macro | removed v1.9.542 | added v1.9.14 | Edit |
(fspec & {:keys [args ret fn gen]})
Source docstring:
takes :args :ret and (optional) :fn kwargs whose values are preds
and returns a spec whose conform/explain take a fn and validates it
using generative testing. The conformed value is always the fn itself.
See 'fdef' for a single operation that creates an fspec and
registers it, as well as a full description of :args, :ret and :fn
fspecs can generate functions that validate the arguments and
fabricate a return value compliant with the :ret spec, ignoring
the :fn spec if present.
Optionally takes :gen generator-fn, which must be a fn of no args
that returns a test.check generator.
(defmacro fspec
[& {:keys [args ret fn gen]}]
(let [env &env]
`(fspec-impl (spec ~args) '~(res env args)
(spec ~ret) '~(res env ret)
(spec ~fn) '~(res env fn) ~gen)))