ex_unit_assertions v0.2.0 ExUnitAssertions

Summary

Functions

Matches pattern in list

Functions

match_in?(pattern, expr) (macro)
match_in?(term, term, [term]) :: true | false

Matches pattern in list:

> match_in?(1, [1, 2, 3])
1

> match_in?(%{a: 1}, [%{a: 1, b: 2}, %{a: 2, b: 3}])
%{a: 1, b: 2}

> match_in?(%{a: 1}, [%{a: 2, b: 2}, %{a: 2, b: 3}])
raised error

> a = 1
> match_in?(%{a: ^a}, [%{a: 1, b: 2}, %{a: 2, b: 3}])
%{a: 1, b: 2}

> match_in?(%{a: 1, b: b}, [%{a: 1, b: 2}, %{a: 2, b: 3}])
%{a: 1, b: 2}
> b
2