test_match v3.0.5 RecursiveMatch
Recursive matching
Link to this section Summary
Functions
Matches given value with pattern
Matches given value with pattern
Matches given value with pattern
Link to this section Functions
assert_match(left, right, options \\ [strict: true]) (macro)
Matches given value with pattern
Returns true or raises ExUnit.AssertionError
Parameters
pattern: Expected pattern (use
:_instead of_)tested: Tested value
options: Options
strict: when
truecompare using===, whenfalsecompare using==, defaulttrueignore_order, whentrue- ignore order of items in lists, defaultfalsemessage: Custom message on fail
Example
The assertion
assert_match %{a: 1}, %{a: 1, b: 2}
will match,
assert_match %{a: 1, b: 2}, %{a: 1}
will fail with the message:
match (assert_match) failed
left: %{a: 1, b: 2},
right: %{a: 1}
match_r(pattern, tested, options \\ [strict: true])
Matches given value with pattern
Returns true or false
Parameters
pattern: Expected pattern (use
:_instead of_)tested: Tested value
options: Options
strict, whentruecompare using===, whenfalsecompare using==, defaulttrueignore_order, whentrue- ignore order of items in lists, defaultfalse
Example
iex> import RecursiveMatch
RecursiveMatch
iex> match_r %{a: 1}, %{a: 1, b: 2}
true
iex> match_r %{a: 1, b: 2}, %{a: 1}
false
prepare_left_for_diff(pattern, tested, options)
prepare_right_for_diff(pattern, tested, options)
refute_match(left, right, options \\ [strict: true]) (macro)
Matches given value with pattern
Returns true or raises ExUnit.AssertionError
Parameters
pattern: Expected pattern (use
:_instead of_)tested: Tested value
options: Options
strict: when
truecompare using===, whenfalsecompare using==, defaulttrueignore_order, whentrue- ignore order of items in lists, defaultfalsemessage: Custom message on fail
Example
The assertion
assert_match %{a: 1}, %{a: 1, b: 2}
will match,
assert_match %{a: 1, b: 2}, %{a: 1}
will fail with the message:
match (refute_match) succeeded, but should have failed