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.
(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
.
Matcher that will match when the given value is exactly the same as the `expected`.
(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.
Similar to Midje's (just expected :in-any-order)
Matcher that will match when the given a list that is the same as the `expected` list but with elements in a different order. Similar to Midje's `(just expected :in-any-order)`
(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)
Matcher that will match when pred
of the actual value returns true.
Matcher that will match when `pred` of the actual value returns true.
(prefix expected)
Matcher that will match when provided a (ordered) prefix of the expected
list.
Similar to Midje's (embeds expected)
Matcher that will match when provided a (ordered) prefix of the `expected` list. Similar to Midje's `(embeds expected)`
(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.
(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.
(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