Liking cljdoc? Tell your friends :D
Clojure only.

clojure.test.generative


defspeccljmacro

(defspec name fn-to-test args & validator-body)

Defines a function named name that expects args. The defined function binds '%' to the result of calling fn-to-test with args, and runs validator-body forms (if any), which have access to both args and %. The defined function.

Args must have type hints (i.e. :tag metadata), which are interpreted as instructions for generating test input data. Unquoted names in type hints are resolved in the c.t.g.generators namespace, which has generator functions for common Clojure data types. For example, the following argument list declares that 'seed' is an int, and that 'iters' is an int in the uniform distribution from 1 to 100:

[^int seed ^{:tag (uniform 1 100)} iters]

Backquoted names in an argument list are resolved in the current namespace, allowing arbitrary generators, e.g.

[^{:tag `scary-word} word]

The function c.t.g.runner/run-iter takes a var naming a test, and runs a single test iteration, generating inputs based on the arg type hints.

Defines a function named name that expects args. The defined
function binds '%' to the result of calling fn-to-test with args,
and runs validator-body forms (if any), which have access to both
args and %. The defined function.

Args must have type hints (i.e. :tag metadata), which are
interpreted as instructions for generating test input
data. Unquoted names in type hints are resolved in the
c.t.g.generators namespace, which has generator functions for
common Clojure data types. For example, the following argument list
declares that 'seed' is an int, and that 'iters' is an int in the
uniform distribution from 1 to 100:

    [^int seed ^{:tag (uniform 1 100)} iters]

Backquoted names in an argument list are resolved in the current
namespace, allowing arbitrary generators, e.g.

    [^{:tag `scary-word} word]

The function c.t.g.runner/run-iter takes a var naming a test, and runs
a single test iteration, generating inputs based on the arg type hints.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close