View Source Machete.ListMatcher (Machete v0.2.8)
Defines a matcher that matches lists
Summary
Types
Describes the arguments that can be passed to this matcher
Describes an instance of this matcher
Functions
Matches lists. Useful for cases where you wish to match against the general shape / size of a list, but cannot match against a literal list
Types
@type opts() :: [ elements: Machete.Matchable.t(), length: non_neg_integer(), min: non_neg_integer(), max: non_neg_integer() ]
Describes the arguments that can be passed to this matcher
@opaque t()
Describes an instance of this matcher
Functions
Matches lists. Useful for cases where you wish to match against the general shape / size of a list, but cannot match against a literal list
Takes the following arguments:
elements
: A matcher to use against all elements in the listlength
: Requires the matched list to be exactly the specified lengthmin
: Requires the matched list to be greater than or equal to the specified lengthmax
: Requires the matched list to be less than or equal to the specified length
Examples:
iex> assert [1] ~> list(elements: integer())
true
iex> assert [1] ~> list(length: 1)
true
iex> assert [1] ~> list(min: 1)
true
iex> assert [1] ~> list(max: 2)
true