Liking cljdoc? Tell your friends :D

matcher-combinators.matchers


absentclj/s

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.
sourceraw docstring

all-ofclj/s

(all-of & matchers)

A matcher that successfully matches if all provided matchers match.

A matcher that successfully matches if all provided matchers match.
sourceraw docstring

any-ofclj/s

(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.
sourceraw docstring

cljs-uricljs

(cljs-uri expected)
source

embedsclj/s

(embeds expected)

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.
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.
sourceraw docstring

equalsclj/s

(equals expected)

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.
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.
sourceraw docstring

in-any-orderclj/s

(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.
sourceraw docstring

lookup-matcherclj/s

(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.
sourceraw docstring

match-withclj/s

(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.
sourceraw docstring

matcher-forclj/s

(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).
sourceraw docstring

mismatchclj/s

(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
sourceraw docstring

nested-equalsclj/s

(nested-equals expected)

A matcher that always uses the equals matcher at every level of nesting.

Useful given that matchers usually only change the first level of the data they are applied to, leaving nested data to use the default matcher of that type of data. For instance, this can be used to assert that any nested map has exactly the same keys and matching values as provided in the expected, and no more.

Note: this excludes functions, which continue to be invoked as predicates, and regex, which continue to be invoked with regex, instead of being compared via the equals matcher.

A matcher that always uses the `equals` matcher at every level of nesting.

Useful given that matchers usually only change the first level of the data
they are applied to, leaving nested data to use the default matcher of that
type of data. For instance, this can be used to assert that any nested map
has exactly the same keys and matching values as provided in the `expected`,
and no more.

Note: this excludes functions, which continue to be invoked
as predicates, and regex, which continue to be invoked with `regex`,
instead of being compared via the `equals` matcher.
sourceraw docstring

predclj/s

(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.
sourceraw docstring

prefixclj/s

(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.
sourceraw docstring

regexclj/s

(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.
sourceraw docstring

seq-ofclj/s

(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.
sourceraw docstring

set-embedsclj/s

(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.
sourceraw docstring

set-equalsclj/s

(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.
sourceraw docstring

viaclj/s

(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}"]}))
```
sourceraw docstring

within-deltaclj/s

(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>))
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close