View Source Machete.FloatMatcher (Machete v0.2.3)

Defines a matcher that matches float values

Link to this section Summary

Types

Describes the arguments that can be passed to this matcher

t()

Describes an instance of this matcher

Functions

Matches against float values

Link to this section Types

@type opts() :: [
  positive: boolean(),
  negative: boolean(),
  nonzero: boolean(),
  min: float(),
  max: float()
]

Describes the arguments that can be passed to this matcher

@opaque t()

Describes an instance of this matcher

Link to this section Functions

@spec float(opts()) :: t()

Matches against float values

Takes the following arguments:

  • positive: When true, requires the matched float be positive or zero
  • negative: When true, requires the matched float be negative or zero
  • nonzero: When true, requires the matched float be nonzero
  • min: Requires the matched float be greater than or equal to the specified value
  • max: Requires the matched float be less than or equal to the specified value

Examples:

iex> assert 1.0 ~> float()
true

iex> assert 1.0 ~> float(positive: true)
true

iex> assert 0.0 ~> float(positive: true)
true

iex> assert -1.0 ~> float(positive: false)
true

iex> refute 0.0 ~> float(positive: false)
false

iex> assert -1.0 ~> float(negative: true)
true

iex> assert 0.0 ~> float(negative: true)
true

iex> assert 1.0 ~> float(negative: false)
true

iex> refute 0.0 ~> float(negative: false)
false

iex> assert 1.0 ~> float(nonzero: true)
true

iex> assert 0.0 ~> float(nonzero: false)
true

iex> assert 2.0 ~> float(min: 2.0)
true

iex> assert 2.0 ~> float(max: 2.0)
true