test_match v1.0.0 RecursiveMatch behaviour

Recursive matching

Link to this section Summary

Callbacks

Recursive matches given value with pattern

Recursive matches given value with pattern

Link to this section Types

Link to this type opts()
opts() :: list() | nil

Link to this section Functions

Link to this function match_r(pattern, tested, options \\ [exactly: true])
match_r(any(), any(), opts()) :: boolean()

Link to this section Callbacks

Link to this callback assert_match(any, any, opts)
assert_match(any(), any(), opts()) :: boolean()

Recursive matches given value with pattern

Returns true or raises ExUnit.AssertionError

Parameters

  • pattern: Expected pattern

  • tested: Tested value

  • opts:

    • exactly: when true compare using ===, when false compare using ==

    • message: Custom message on faile

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}
Link to this callback refute_match(any, any, opts)
refute_match(any(), any(), opts()) :: boolean()

Recursive matches given value with pattern

Returns true or raises ExUnit.AssertionError

Parameters

  • pattern: Expected pattern

  • tested: Tested value

  • opts:

    • exactly: when true compare using ===, when false compare using ==

    • message: Custom message on faile

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