(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.
cljdoc builds & hosts documentation for Clojure/Script libraries
Ctrl+k | Jump to recent docs |
← | Move to previous article |
→ | Move to next article |
Ctrl+/ | Jump to the search field |