This namespace provides compatibility with clojure.test and related tooling.
This namespace should be used standalone, without requiring the 'expectations' namespace -- this provides a translation layer from Expectations syntax down to clojure.test functionality.
We do not support ClojureScript in clojure.test mode, sorry.
This namespace provides compatibility with clojure.test and related tooling. This namespace should be used standalone, without requiring the 'expectations' namespace -- this provides a translation layer from Expectations syntax down to clojure.test functionality. We do not support ClojureScript in clojure.test mode, sorry.
(approximately v)
(approximately v d)
Given a value and an optional delta (default 0.001), return a predicate that expects its argument to be within that delta of the given value.
Given a value and an optional delta (default 0.001), return a predicate that expects its argument to be within that delta of the given value.
(between a b)
Given a pair of (numeric) values, return a predicate that expects its argument to be be those values or between them -- inclusively.
Given a pair of (numeric) values, return a predicate that expects its argument to be be those values or between them -- inclusively.
(between' a b)
Given a pair of (numeric) values, return a predicate that expects its argument to be (strictly) between those values -- exclusively.
Given a pair of (numeric) values, return a predicate that expects its argument to be (strictly) between those values -- exclusively.
(defexpect n & body)
Given a name (a symbol that may include metadata) and a test body, produce a standard 'clojure.test' test var (using 'deftest').
(defexpect name expected actual)
is a special case shorthand for
(defexpect name (expect expected actual))
provided as an easy way to migrate
legacy Expectation tests to the 'clojure.test' compatibility version.
Given a name (a symbol that may include metadata) and a test body, produce a standard 'clojure.test' test var (using 'deftest'). `(defexpect name expected actual)` is a special case shorthand for `(defexpect name (expect expected actual))` provided as an easy way to migrate legacy Expectation tests to the 'clojure.test' compatibility version.
(expect a)
(expect e a)
(expect e a msg)
(expect e a msg ex? e')
Translate Expectations DSL to clojure.test language.
These are approximate translations for the most basic forms:
(expect actual)
=> (is actual)
(expect expected actual)
=> (is (= expected actual))
(expect predicate actual)
=> (is (predicate actual))
(expect regex actual)
=> (is (re-find regex actual))
(expect ClassName actual)
=> (is (instance? ClassName actual))
(expect ExceptionType actual)
=> (is (thrown? ExceptionType actual))
(expect spec actual)
=> (is (s/valid? spec actual))
An optional third argument can be provided: a message to be included in the output if the test fails.
In addition, actual
can be (from-each [x coll] (computation-of x))
or (in set-of-results)
or (in larger-hash-map)
.
Also, expect
can be one of (more predicate1 .. predicateN)
,
(more-> exp1 expr1 .. expN exprN)
where actual
is threaded through
each expression exprX
and checked with the expected value expX
,
or (more-of binding exp1 val1 .. expN valN)
where actual
is
destructured using the binding
and then each expected value expX
is used to check each valX
-- expressions based on symbols in the
binding
.
Translate Expectations DSL to clojure.test language. These are approximate translations for the most basic forms: `(expect actual)` => `(is actual)` `(expect expected actual)` => `(is (= expected actual))` `(expect predicate actual)` => `(is (predicate actual))` `(expect regex actual)` => `(is (re-find regex actual))` `(expect ClassName actual)` => `(is (instance? ClassName actual))` `(expect ExceptionType actual)` => `(is (thrown? ExceptionType actual))` `(expect spec actual)` => `(is (s/valid? spec actual))` An optional third argument can be provided: a message to be included in the output if the test fails. In addition, `actual` can be `(from-each [x coll] (computation-of x))` or `(in set-of-results)` or `(in larger-hash-map)`. Also, `expect` can be one of `(more predicate1 .. predicateN)`, `(more-> exp1 expr1 .. expN exprN)` where `actual` is threaded through each expression `exprX` and checked with the expected value `expX`, or `(more-of binding exp1 val1 .. expN valN)` where `actual` is destructured using the `binding` and then each expected value `expX` is used to check each `valX` -- expressions based on symbols in the `binding`.
(expecting string & body)
The Expectations version of clojure.test/testing
.
The Expectations version of `clojure.test/testing`.
(functionally expected-fn actual-fn)
(functionally expected-fn actual-fn difference-fn)
Given a pair of functions, return a custom predicate that checks that they return the same result when applied to a value. May optionally accept a 'difference' function that should accept the result of each function and return a string explaininhg how they actually differ. For explaining strings, you could use expectations/strings-difference. (only when I port it across!)
Right now this produces pretty awful failure messages. FIXME!
Given a pair of functions, return a custom predicate that checks that they return the same result when applied to a value. May optionally accept a 'difference' function that should accept the result of each function and return a string explaininhg how they actually differ. For explaining strings, you could use expectations/strings-difference. (only when I port it across!) Right now this produces pretty awful failure messages. FIXME!
If Humane Test Output is available, activate it, and enable compatibility of our =? with it.
If Humane Test Output is available, activate it, and enable compatibility of our =? with it.
(side-effects fn-vec & forms)
Given a vector of functions to track calls to, execute the body.
Returns a vector of each set of arguments used in calls to those
functions. The specified functions will not actually be called:
only their arguments will be tracked. If you need the call to return
a specific value, the function can be given as a pair of its name
and the value you want its call(s) to return. Functions given just
by name will return nil
.
Given a vector of functions to track calls to, execute the body. Returns a vector of each set of arguments used in calls to those functions. The specified functions will not actually be called: only their arguments will be tracked. If you need the call to return a specific value, the function can be given as a pair of its name and the value you want its call(s) to return. Functions given just by name will return `nil`.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close