is-approx
ErrorsCollection

is-approx

Synthesised documentation from type/Test

From type/Test

See Original text in context

multi sub is-approx(Numeric $gotNumeric $expected$desc = '')
multi sub is-approx(Numeric $gotNumeric $expectedNumeric $abs-tol,
                    $desc = '')
multi sub is-approx(Numeric $gotNumeric $expected$desc = '',
                    Numeric :$rel-tol is required)
multi sub is-approx(Numeric $gotNumeric $expected$desc = '',
                    Numeric :$abs-tol is required)
multi sub is-approx(Numeric $gotNumeric $expected$desc = '',
                    Numeric :$rel-tol is required,
                    Numeric :$abs-tol is required)

Marks a test as passed if the $got and $expected numerical values are approximately equal to each other. The subroutine can be called in numerous ways that let you test using relative tolerance ($rel-tol) or absolute tolerance ($abs-tol) of different values.

If no tolerance is set, the function will base the tolerance on the absolute value of $expected: if it's smaller than 1e-6, use absolute tolerance of 1e-5; if it's larger, use relative tolerance of 1e-6.

my Numeric ($value$expected$abs-tol$rel-tol= ...
 
is-approx $value$expected;
is-approx $value$expected'test description';
 
is-approx $value$expected$abs-tol;
is-approx $value$expected$abs-tol'test description';
 
is-approx $value$expected:$rel-tol;
is-approx $value$expected:$rel-tol'test description';
 
is-approx $value$expected:$abs-tol;
is-approx $value$expected:$abs-tol'test description';
 
is-approx $value$expected:$abs-tol:$rel-tol;
is-approx $value$expected:$abs-tol:$rel-tol'test description';