(all* c & cs)
Takes one or more checker
s, and returns a new checker
.
That checker takes an actual
argument, and calls every checker with it as the first and only argument.
Returns nil or a sequence of maps matching check-failure?
.
Takes one or more `checker`s, and returns a new `checker`. That checker takes an `actual` argument, and calls every checker with it as the first and only argument. Returns nil or a sequence of maps matching `check-failure?`.
(and* c & cs)
Takes one or more checker
s, and returns a new checker
.
That checker takes an actual
argument, and calls each checker in succession, short circuiting if any returned a check-failure?
.
Returns nil or a sequence of maps matching check-failure?
.
Takes one or more `checker`s, and returns a new `checker`. That checker takes an `actual` argument, and calls each checker in succession, short circuiting if any returned a `check-failure?`. Returns nil or a sequence of maps matching `check-failure?`.
(append-message message failures)
WARNING: INTERNAL HELPER, DO NOT USE!
WARNING: INTERNAL HELPER, DO NOT USE!
(check-expr cljs? msg [_ checker actual])
WARNING: FOR INTERNAL USE ONLY, DO NOT USE!
WARNING: FOR INTERNAL USE ONLY, DO NOT USE!
(checker arglist & args)
Creates a function that takes only one argument (usually named actual
).
For use in =check=> assertions.
NOTE: the fact that a checker is just a fn with metadata is an internal detail, do not rely on that fact, and prefer usage of this checker
macro.
Creates a function that takes only one argument (usually named `actual`). For use in =check=> assertions. NOTE: the fact that a checker is just a fn with metadata is an internal detail, do not rely on that fact, and prefer usage of this `checker` macro.
(checker? x)
Checks if passed in argument was a function created by the checker
macro.
NOTE: the fact that a checker is just a fn with metadata is an internal detail, do not rely on that fact, and prefer usage of the checker
macro.
Checks if passed in argument was a function created by the `checker` macro. NOTE: the fact that a checker is just a fn with metadata is an internal detail, do not rely on that fact, and prefer usage of the `checker` macro.
(embeds?* expected)
Takes a map and returns a checker that checks if the values at the keys match (using =
) .
The map values can be checker
s, but will throw an error if passed a raw function.
The map can be arbitrarily nested with further maps, eg:
(embeds?* {:a 1, :b {:c (is?* even?)}}) =check=> {:a 1, :b {:c 2}}
Can also check that a key value pair was not found by checking for equality with ::not-found, eg:
(embeds?* {:a ::not-found}) =check=> {}
Takes a map and returns a checker that checks if the values at the keys match (using `=`) . The map values can be `checker`s, but will throw an error if passed a raw function. The map can be arbitrarily nested with further maps, eg: ``` (embeds?* {:a 1, :b {:c (is?* even?)}}) =check=> {:a 1, :b {:c 2}} ``` Can also check that a key value pair was not found by checking for equality with ::not-found, eg: ``` (embeds?* {:a ::not-found}) =check=> {} ```
(equals?* expected)
Takes any value and returns a checker that checks for equality.
Takes any value and returns a checker that checks for equality.
(every?* c & cs)
Takes one or more checkers, and returns a checker that runs all checker arguments on each element of the checker argument sequence.
WARNING: checks every item in the actual
sequence, unlike every?
.
WARNING: will pass if given an empty sequence, like every?
.
If not desireable, compose (is?* seq)
or (of-length? ...)
before this checker.
NOTE: will short circuit execution of expected checkers using the same semantics as and*
.
Takes one or more checkers, and returns a checker that runs all checker arguments on each element of the checker argument sequence. WARNING: checks every item in the `actual` sequence, unlike `every?`. WARNING: will pass if given an empty sequence, like `every?`. If not desireable, compose `(is?* seq)` or `(of-length? ...)` before this checker. NOTE: will short circuit execution of expected checkers using the same semantics as `and*`.
(ex-data* c & cs)
Checks that the actual
value is an ExceptionInfo
.
If successful, passes the ex-data
to all*
passed in checkers.
Checks that the `actual` value is an `ExceptionInfo`. If successful, passes the `ex-data` to `all*` passed in checkers.
(exception* c & cs)
Checks that the actual
value is an Exception
(or in cljs a js/Error
).
If successful, passes the Exception
to all*
passed in checkers.
Checks that the `actual` value is an `Exception` (or in cljs a `js/Error`). If successful, passes the `Exception` to `all*` passed in checkers.
(exists?* & [msg])
Takes an optional failure message and returns a checker that checks for non-nil values.
Takes an optional failure message and returns a checker that checks for non-nil values.
(fmap* f c)
Creates a new checker that is the result of applying the function to the checker arguments before passing it to the wrapped checker.
Eg: 0 =check=> (fmap* inc (equals?* 1))
Creates a new checker that is the result of applying the function to the checker arguments before passing it to the wrapped checker. Eg: `0 =check=> (fmap* inc (equals?* 1))`
(in* path c & cs)
Takes a path and one or more checkers, and returns a checker that focuses the checker argument on the result of running (get-in actual path)
.
If the call to get-in
failed it returns a check-failure?
.
Takes a path and one or more checkers, and returns a checker that focuses the checker argument on the result of running `(get-in actual path)`. If the call to `get-in` failed it returns a `check-failure?`.
(is?* predicate)
Takes any truthy predicate function and returns a checker that checks with said predicate.
Takes any truthy predicate function and returns a checker that checks with said predicate.
(of-length?* expected-length)
(of-length?* min-len max-len)
Checks that given seqable?
collection has the expected length.
Has two arities:
expected-length
.Checks that given `seqable?` collection has the expected length. Has two arities: - The first checks that the actual length is equal to the `expected-length`. - The second, takes two numbers and verifies that the actual length is between (inclusively) the two numbers.
(prepend-message msg fail)
WARNING: INTERNAL HELPER, DO NOT USE!
WARNING: INTERNAL HELPER, DO NOT USE!
(re-find?* regex)
Takes a regex (or string) and returns a checker that checks using re-find
.
NOTE: Will first check that the incoming data (actual
) is a string?
Takes a regex (or string) and returns a checker that checks using `re-find`. NOTE: Will first check that the incoming data (`actual`) is a `string?`
(seq-matches-exactly?* expected)
Takes a sequential?
collection, and returns a checker that checks its argument in a sequential manner.
NOTE: "exactly" means that the actual
collection is checked to have the exact same length as the expected
collection.
Eg:
(seq-matches?* [1 2]) =check=> [1 2]
Can also take checkers as values, eg:
(seq-matches?* [(is?* pos?)]) =check=> [42]
Takes a `sequential?` collection, and returns a checker that checks its argument in a sequential manner. NOTE: "exactly" means that the `actual` collection is checked to have the **exact** same length as the `expected` collection. Eg: `(seq-matches?* [1 2]) =check=> [1 2]` Can also take checkers as values, eg: `(seq-matches?* [(is?* pos?)]) =check=> [42]`
(seq-matches?* expected)
Takes a sequential?
collection, and returns a checker that checks its argument in a sequential manner, ie:
(seq-matches?* [1 2]) =check=> [1 2]
NOTE: does NOT check if the actual
collection contains more or fewer items than expected! If not desireable, use seq-matches-exactly?*
instead.
Can also take checkers as values, eg:
(seq-matches?* [(is?* pos?)]) =check=> [42]
Takes a `sequential?` collection, and returns a checker that checks its argument in a sequential manner, ie: `(seq-matches?* [1 2]) =check=> [1 2]` NOTE: does **NOT** check if the `actual` collection contains more or fewer items than expected! If not desireable, use `seq-matches-exactly?*` instead. Can also take checkers as values, eg: `(seq-matches?* [(is?* pos?)]) =check=> [42]`
(subset?* expected)
Takes an expected
set, and will check that actual
contains only a subset of what is expected.
Eg:
; PASSES
#{:a} =check=> (subset?* #{:a :b})
; FAILS
#{:a :b :c} =check=> (subset?* #{:a :b})
Takes an `expected` set, and will check that `actual` contains only a subset of what is expected. Eg: ``` ; PASSES #{:a} =check=> (subset?* #{:a :b}) ; FAILS #{:a :b :c} =check=> (subset?* #{:a :b}) ```
(throwable* c & cs)
Checks that the actual
value is a Throwable
(or in cljs a js/Error
).
If successful, passes the Throwable
to all*
passed in checkers.
Checks that the `actual` value is a `Throwable` (or in cljs a `js/Error`). If successful, passes the `Throwable` to `all*` passed in checkers.
(valid?* spec)
Takes any valid clojure.spec.alpha/spec and returns a checker.
The checker checks with s/valid?
and calls s/explain-str
for the :message
.
Takes any valid clojure.spec.alpha/spec and returns a checker. The checker checks with `s/valid?` and calls `s/explain-str` for the `:message`.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close