File: number.t

package info (click to toggle)
libregexp-common-perl 2016060801-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,324 kB
  • ctags: 229
  • sloc: perl: 17,854; makefile: 2
file content (40 lines) | stat: -rwxr-xr-x 910 bytes parent folder | download | duplicates (4)
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
#!/usr/bin/perl

#
# Test for the support functions of Regexp::Common::number
#

use strict;
use lib  qw {blib/lib};

use Regexp::Common;
use t::Common;

my @wrong_bases   = (0, 40);
my @correct_bases = (1, 29, 36);
my @types         = qw /decimal real/;

my $tests = (@wrong_bases + @correct_bases) * @types;
my $count = 0;

print "1..$tests\n";

foreach my $base (@wrong_bases) {
    foreach my $type (@types) {
        eval {"" =~ $RE {num} {$type} {-base => $base}};
        printf "%s %d - \$RE {num} {$type} {-base => $base}\n" =>
                $@ && $@ =~ /Base must be between 1 and 36/ ? "ok" : "not ok",
                ++ $count;
    }
}

foreach my $base (@correct_bases) {
    foreach my $type (@types) {
        eval {"" =~ $RE {num} {$type} {-base => $base}};
        printf "%s %d - \$RE {num} {$type} {-base => $base}\n" =>
                $@ ? "not ok" : "ok", ++ $count;
    }
}


__END__