Testing module

require_near

procedureextensionsince 0.28.0Source

expect_near, then returns from the calling procedure on a failure.

Example↗
require_near(0.1 + 0.2, 0.3, 0.0001);
require_near :: (
    got: float64,
    want: float64,
    tolerance: float64,
    loc := #caller_location
)

expect_near, then returns from the calling procedure on a failure.

Parameters

got: float64
the value under test.
want: float64
the value it should be close to.
tolerance: float64
the largest allowed difference.
loc := #caller_location
where the check is written, shown when it fails. Leave the default.
Example↗
require_near(0.1 + 0.2, 0.3, 0.0001);

See also