File: stringify_as.t

package info (click to toggle)
libnumber-tolerant-perl 1.710-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 372 kB
  • sloc: perl: 757; makefile: 10
file content (51 lines) | stat: -rw-r--r-- 1,087 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
use Test::More tests => 9;

use strict;
use warnings;

BEGIN { use_ok("Number::Tolerant"); }

{ # plusminus
  my $tol = tolerance(10 => plus_or_minus => 2);
  is($tol->stringify, "10 +/- 2", "plus_or_minus");
  TODO: { local $TODO = "stringify_as not soup yet";
    is(
      $tol->stringify_as('plus_or_minus_pct'),
      "10 +/- 20%",
      "plus_or_minus as _pct"
    );
  }
}

{ # plusminus_pct
  my $tol = tolerance(10 => plus_or_minus_pct => 10);
  is($tol->stringify, "10 +/- 10%", "plus_or_minus_pct");
  TODO: { local $TODO = "stringify_as not soup yet";
    is(
      $tol->stringify_as('plus_or_minus'),
      "10 +/- 1",
      "plus_or_minus_pct as plus_or_minus"
    );
  }
}

{ # or_less
  my $tol = tolerance(10 => 'or_less');
  is($tol->stringify, "x <= 10", "or_less");
}

{ # or_more
  my $tol = tolerance(10 => 'or_more');
  is($tol->stringify, "10 <= x", "or_more");
}

{ # x_to_y
  my $tol = tolerance(8 => to => 12);
  is($tol->stringify, "8 <= x <= 12", "to");
}


{ # infinite
  my $tol = tolerance("infinite");
  is($tol->stringify, "any number", "infinite");
}