Test::Tolerant(3pm)

Test::Tolerant3pm

Test routines for testing numbers against tolerances

Usage

  use Test::More;
  use Test::Tolerant;
  my $total = rand(6) + rand(6) + rand(6);
  is_tol(10, [ qw( 3 to 18 ) ], "got an acceptable result from random dice");
  done_testing;

Version

version 1.710

Perl version

This library should run on perls released even a long time ago. It should work on any version of perl released in the last five years.

Although it may work on older versions of perl, no guarantee is made that the minimum required version will not be increased. The version may be increased for any reason, and there is no promise that patches will be accepted to lower the minimum required perl.

Functions

is_tol

  is_tol($have, $want_spec, $comment);

"is_tol" is the only routine provided by Test::Tolerant, and is exported by default. It beahves like "is" from Test::More, asserting that two values must be equal, but it will always use numeric equality, and the second argument is not always used as the right hand side of comparison directly, but it used to produce a Number::Tolerant to compare to.

$have_spec can be:

  * a Number::Tolerant object
  * an arrayref of args to Number::Tolerant->new
  * a string to be passed to Number::Tolerant->from_string
    * a literal number falls under this group

If the value is outside of spec, you'll get a diagnostic message something like this:

  given value is outside acceptable tolerances
      have: 3
      want: 5 < x

Releases

6 releases since Debian 8 (Jessie); the text changed 2 times.

  1. 8
  2. 9–11
  3. 12–13

Author

Ricardo Signes <[email protected]>

From libnumber-tolerant-perl 1.710-1 in Debian 13 (Trixie). Parsed by carta from the page's man source.