(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?`.
(assert-are-checkers! tag checkers)
Helper to ensure that checker "combinators" are passed checkers.
The tag can be anything, but by convention should be the namespaced qualified symbol of the checker this function is inside of.
eg: (assert-are-checkers!
and* checkers)`
Helper to ensure that checker "combinators" are passed checkers. The tag can be anything, but by convention should be the namespaced qualified symbol of the checker this function is inside of. eg: `(assert-are-checkers! `and* checkers)`
(assert-is! tag pred value)
Helper macro to assert that values satisfy a predicate.
The tag can be anything, but by convention should be the namespaced qualified symbol of the checker this function is inside of.
eg: (assert-is!
is?* ifn? predicate)`
Helper macro to assert that values satisfy a predicate. The tag can be anything, but by convention should be the namespaced qualified symbol of the checker this function is inside of. eg: `(assert-is! `is?* ifn? predicate)`
(behavior* string c & cs)
NOTE: experimental, may be considered poor form and deprecated at a later date.
Equivalent to fulcro-spec.core/behavior
, so you can describe the expected behavior being checked.
eg: 2.0 =check=> (_/behavior* "is a double" (_/is?* double?))
NOTE: experimental, may be considered poor form and deprecated at a later date. Equivalent to `fulcro-spec.core/behavior`, so you can describe the expected behavior being checked. eg: `2.0 =check=> (_/behavior* "is a double" (_/is?* double?))`
(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: [:b :c :a] =check=> (fmap* sort (equals?* [:a :b :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: `[:b :c :a] =check=> (fmap* sort (equals?* [:a :b :c]))`
(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.
(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-exactly?* [1 2]) =check=> [1 2]
Can also take checkers as values, eg:
(seq-matches-exactly?* [(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-exactly?* [1 2]) =check=> [1 2]` Can also take checkers as values, eg: `(seq-matches-exactly?* [(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`.
(with-message* message c & cs)
Appends the message to all failures that the checker may return.
eg: 2.0 =check=> (_/with-message* "some info" (_/is?* double?))
Appends the message to all failures that the checker may return. eg: `2.0 =check=> (_/with-message* "some info" (_/is?* double?))`
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close