Value-position matcher for maps that matches when containing map doesn't have the key pointing to this matcher.
Value-position matcher for maps that matches when containing map doesn't have the key pointing to this matcher.
(all-of & matchers)
A matcher that successfully matches if all provided matchers match.
A matcher that successfully matches if all provided matchers match.
(any-of & matchers)
A matcher that successfully matches if one of the two provided matchers matches.
A matcher that successfully matches if one of the two provided matchers matches.
(embeds expected)
Matcher for asserting that the expected is embedded in the actual.
Behaviour differs depending on the form of the expected
:
expected
map.expected
sequence.expected
set can be
matched with an element in the provided set. There may be more
elements in the provided set than there are matchers.Matcher for asserting that the expected is embedded in the actual. Behaviour differs depending on the form of the `expected`: - map: matches when the map contains some of the same key/values as the `expected` map. - sequence: order-agnostic matcher that will match when provided a subset of the `expected` sequence. - set: matches when all the matchers in the `expected` set can be matched with an element in the provided set. There may be more elements in the provided set than there are matchers.
(equals expected)
Matcher that will match when the given value is exactly the same as the
expected
.
When expected
is:
actual
must
match a corresponding element in expected
. Consistent with other matchers,
equals is not recursively applied to sub-elements. This means that nested maps,
for example, continue using their default matcher. If you want to do a deep
match, consider using match-with
instead.Matcher that will match when the given value is exactly the same as the `expected`. When `expected` is: - A scalar or function: Value equality is used - A composite data-structure (map, vector, etc): each element in `actual` must match a corresponding element in `expected`. Consistent with other matchers, equals is not recursively applied to sub-elements. This means that nested maps, for example, continue using their default matcher. If you want to do a deep match, consider using `match-with` instead.
(in-any-order expected)
Matcher that will match when the given a list that is the same as the
expected
list but with elements in a different order.
WARNING: in-any-order can match each expected element against every value in the actual sequence, which may be cost prohibitive for large sequences Consider sorting the expected and actual sequences and comparing those instead.
Matcher that will match when the given a list that is the same as the `expected` list but with elements in a different order. WARNING: in-any-order can match each expected element against every value in the actual sequence, which may be cost prohibitive for large sequences Consider sorting the expected and actual sequences and comparing those instead.
(lookup-matcher value pred->matcher-overrides)
Internal use only. Iterates through pred->matcher-overrides and returns the value (a matcher) bound to the first pred that returns true for value. If no override is found, returns the default matcher for value.
The legacy API called for a map of type->matcher, which is still supported by wrapping types in (instance? type %) predicates.
Internal use only. Iterates through pred->matcher-overrides and returns the value (a matcher) bound to the first pred that returns true for value. If no override is found, returns the default matcher for value. The legacy API called for a map of type->matcher, which is still supported by wrapping types in (instance? type %) predicates.
(match-with overrides value)
Given a vector (or map) of overrides, returns the appropriate matcher for value (with value wrapped). If no matcher for value is found in overrides, uses the default: embeds for maps regex for regular expressions equals for everything else
If value is a collection, recursively applies match-with to its nested values, ignoring nested values that are already wrapped in matchers.
NOTE that each nested match-with creates a new context, and nested contexts do not inherit the overrides of their parent contexts.
Given a vector (or map) of overrides, returns the appropriate matcher for value (with value wrapped). If no matcher for value is found in overrides, uses the default: embeds for maps regex for regular expressions equals for everything else If value is a collection, recursively applies match-with to its nested values, ignoring nested values that are already wrapped in matchers. NOTE that each nested match-with creates a new context, and nested contexts do not inherit the overrides of their parent contexts.
(matcher-for expected)
(matcher-for expected overrides)
Returns the type-specific matcher object for an expected value. This is used internally to support the match-with matcher, and is also useful for discovery when you want to know which Matcher type is associated to a value.
Adds :matcher-object? metadata to the returned matcher so that other functions can differentiate between matcher objects and objects that happen to implement the Matcher protocol (which should be all other objects).
Returns the type-specific matcher object for an expected value. This is used internally to support the match-with matcher, and is also useful for discovery when you want to know which Matcher type is associated to a value. Adds :matcher-object? metadata to the returned matcher so that other functions can differentiate between matcher objects and objects that happen to implement the Matcher protocol (which should be all other objects).
(mismatch expected)
Negation matcher that takes in an expected
matcher and passes when it
doesn't match the actual
.
When possible use positive matching instead as negation matching quickly leads to very unreadable match assertions
Negation matcher that takes in an `expected` matcher and passes when it doesn't match the `actual`. When possible use positive matching instead as negation matching quickly leads to very unreadable match assertions
(pred pred-fn)
(pred pred-fn desc)
Matcher that will match when pred-fn
of the actual value returns true.
Matcher that will match when `pred-fn` of the actual value returns true.
(prefix expected)
Matcher that will match when provided a (ordered) prefix of the expected
list.
Matcher that will match when provided a (ordered) prefix of the `expected` list.
(regex expected)
Matcher that will match when given value matches the expected
regular expression.
Matcher that will match when given value matches the `expected` regular expression.
(seq-of expected)
Matcher that will match when given a sequence where every element matches
the provided expected
matcher. It expects a non-empty sequence.
Matcher that will match when given a sequence where every element matches the provided `expected` matcher. It expects a non-empty sequence.
(set-embeds expected)
Matches a set in the way (embeds some-set)
would, but accepts sequences
as the expected matcher argument, allowing one to use matchers with the same
submatcher appearing more than once.
Matches a set in the way `(embeds some-set)` would, but accepts sequences as the expected matcher argument, allowing one to use matchers with the same submatcher appearing more than once.
(set-equals expected)
Matches a set in the way (equals some-set)
would, but accepts sequences as
the expected matcher argument, allowing one to use matchers with the same
submatcher appearing more than once.
Matches a set in the way `(equals some-set)` would, but accepts sequences as the expected matcher argument, allowing one to use matchers with the same submatcher appearing more than once.
(via transform-actual-fn expected)
A matcher that transforms the actual
data-structure before applying the
expected
matcher.
For example, it allows one to match a nested string as an edn map:
(is (match? {:payloads [(m/via read-string {:foo :bar})]}
{:payloads ["{:foo :bar}"]}))
A matcher that transforms the `actual` data-structure before applying the `expected` matcher. For example, it allows one to match a nested string as an edn map: ``` (is (match? {:payloads [(m/via read-string {:foo :bar})]} {:payloads ["{:foo :bar}"]})) ```
(within-delta delta)
(within-delta delta expected)
Given delta
and expected
, returns a Matcher that will match
when the actual value is within delta
of expected
. Given only
delta
, returns a function to be used in the context of match-with
,
e.g.
(is (match? (m/match-with [number? (m/within-delta 0.01M)] <expected>) <actual>))
Given `delta` and `expected`, returns a Matcher that will match when the actual value is within `delta` of `expected`. Given only `delta`, returns a function to be used in the context of `match-with`, e.g. (is (match? (m/match-with [number? (m/within-delta 0.01M)] <expected>) <actual>))
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close