File: test.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 (62 lines) | stat: -rw-r--r-- 930 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
52
53
54
55
56
57
58
59
60
61
62
use strict;
use warnings;

use Test::Tester;

use Test::More;
use Test::Tolerant;


check_test(
  sub { is_tol(5, 'x > 4'); },
  {
    ok   => 1,
    name => '',
    diag => '',
  },
  "successful comparison"
);

check_test(
  sub { is_tol(5, 'x > 5'); },
  {
    ok   => 0,
    name => '',
    diag => <<END_DIAG,
given value is below acceptable tolerances
    have: 5
    want: 5 < x
END_DIAG
  },
  "short, failed comparison"
);

check_test(
  sub { is_tol(5, [ qw(more_than 5) ]); },
  {
    ok   => 0,
    name => '',
    diag => <<END_DIAG,
given value is below acceptable tolerances
    have: 5
    want: 5 < x
END_DIAG
  },
  "short, failed comparison"
);

check_test(
  sub { is_tol(5, Number::Tolerant->new(qw(more_than 5))); },
  {
    ok   => 0,
    name => '',
    diag => <<END_DIAG,
given value is below acceptable tolerances
    have: 5
    want: 5 < x
END_DIAG
  },
  "short, failed comparison"
);

done_testing;