cljs.spec.test.alpha

previously cljs.spec.test

->sym - function
(->sym x)

abbrev-result - function
(abbrev-result x)
Given a check result, returns an abbreviated version
suitable for summary use.

check - macro
(check)
(check sym-or-syms)
(check sym-or-syms opts)
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.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

check-1 - macro
(check-1 [quote s :as qs] f spec opts)

check-fn - macro
(check-fn f spec)
(check-fn f spec opts)
Runs generative tests for fn f using spec and opts. See
'check' for options and return.

checkable-syms - macro
(checkable-syms)
(checkable-syms opts)
Given an opts map as per check, returns the set of syms that
can be checked.

checkable-syms* - function
(checkable-syms*)
(checkable-syms* opts)

distinct-by - function
(distinct-by f coll)

get-env - function
(get-env)

get-host-port - function
(get-host-port)

get-ua-product - function
(get-ua-product)

instrument - macro
(instrument)
(instrument xs)
(instrument sym-or-syms opts)
Instruments the vars named by sym-or-syms, a symbol or collection
of symbols, or all instrumentable vars if sym-or-syms is not
specified. If a symbol identifies a namespace then all symbols in that
namespace will be enumerated.

If a var has an :args fn-spec, sets the var's root binding to a
fn that checks arg conformance (throwing an exception on failure)
before delegating to the original fn.

The opts map can be used to override registered specs, and/or to
replace fn implementations entirely. Opts for symbols not included
in sym-or-syms are ignored. This facilitates sharing a common
options map across many different calls to instrument.

The opts map may have the following keys:

  :spec     a map from var-name symbols to override specs
  :stub     a set of var-name symbols to be replaced by stubs
  :gen      a map from spec names to generator overrides
  :replace  a map from var-name symbols to replacement fns

:spec overrides registered fn-specs with specs your provide. Use
:spec overrides to provide specs for libraries that do not have
them, or to constrain your own use of a fn to a subset of its
spec'ed contract.

:stub replaces a fn with a stub that checks :args, then uses the
:ret spec to generate a return value.

:gen overrides are used only for :stub generation.

:replace replaces a fn with a fn that checks args conformance, then
invokes the fn you provide, enabling arbitrary stubbing and mocking.

:spec can be used in combination with :stub or :replace.

Returns a collection of syms naming the vars instrumented.

instrument-1 - macro
(instrument-1 [quote s] opts)

instrumentable-syms - function
(instrumentable-syms)
(instrumentable-syms opts)
Given an opts map as per instrument, returns the set of syms
that can be instrumented.

summarize-results - function
(summarize-results check-results)
(summarize-results check-results summary-result)
Given a collection of check-results, e.g. from 'check', pretty
prints the summary-result (default abbrev-result) of each.

Returns a map with :total, the total number of results, plus a
key with a count for each different :type of result.

unstrument - macro
(unstrument)
(unstrument sym-or-syms)
Undoes instrument on the vars named by sym-or-syms, specified
as in instrument. With no args, unstruments all instrumented vars.
Returns a collection of syms naming the vars unstrumented.

unstrument-1 - macro
(unstrument-1 [quote s])

with-instrument-disabled - macro
(with-instrument-disabled & body)
Disables instrument's checking of calls, within a scope.