test_match v1.1.1 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
Matches given value with pattern
Returns true
or raises ExUnit.AssertionError
Parameters
pattern: Expected pattern (use
:_
instead of_
)tested: Tested value
opts:
strict: when
true
compare using===
, whenfalse
compare using==
, defaulttrue
message: 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}
Matches given value with pattern
Returns true
or false
Parameters
pattern: Expected pattern (use
:_
instead of_
)tested: Tested value
opts:
- strict, when
true
compare using===
, whenfalse
compare using==
, defaulttrue
- strict, when
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
Matches given value with pattern
Returns true
or raises ExUnit.AssertionError
Parameters
pattern: Expected pattern (use
:_
instead of_
)tested: Tested value
opts:
strict: when
true
compare using===
, whenfalse
compare using==
, defaulttrue
message: 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