API for clojure.spec.test.alpha - spec.alpha 0.1.144-SNAPSHOT (in development)


Full namespace name: clojure.spec.test.alpha

Overview





Public Variables and Functions



abbrev-result

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

    
    
    Source
  


check

function
Usage: (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.

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

    
    
    Source
  


check-fn

function
Usage: (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.

    
    
    Source
  


checkable-syms

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

    
    
    Source
  


enumerate-namespace

function
Usage: (enumerate-namespace ns-sym-or-syms)
Given a symbol naming an ns, or a collection of such symbols,
returns the set of all symbols naming vars in those nses.

    
    
    Source
  


instrument

function
Usage: (instrument)
       (instrument sym-or-syms)
       (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 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.

    
    
    Source
  


instrumentable-syms

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

    
    
    Source
  


summarize-results

function
Usage: (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.

    
    
    Source
  


unstrument

function
Usage: (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.

    
    
    Source
  


with-instrument-disabled

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

    
    
    Source
  
Logo & site design by Tom Hickey.
Clojure auto-documentation system by Tom Faulhaber.