File: TestOrdinal.pm

package info (click to toggle)
liblingua-en-number-isordinal-perl 0.4-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 112 kB
  • ctags: 7
  • sloc: perl: 170; makefile: 2
file content (46 lines) | stat: -rw-r--r-- 936 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
41
42
43
44
45
46
package TestOrdinal;

use strict;
use warnings;
use Test::More;
use Exporter 'import';
use Try::Tiny;
use Lingua::EN::Number::IsOrdinal ();

our @EXPORT_OK = qw/is_ordinal is_not_ordinal/;

sub is_ordinal {
    my $num = shift;

    try {
        my $test = Lingua::EN::Number::IsOrdinal::is_ordinal($num);

        local $Test::Builder::Level = $Test::Builder::Level + 3;

        ok($test, "'$num' is an ordinal number");
    }
    catch {
        local $Test::Builder::Level = $Test::Builder::Level + 3;

        fail "'$num' is not a number";
    };
}

sub is_not_ordinal {
    my $num = shift;

    try {
        my $test = !Lingua::EN::Number::IsOrdinal::is_ordinal($num);

        local $Test::Builder::Level = $Test::Builder::Level + 3;

        ok($test, "'$num' is NOT an ordinal number");
    }
    catch {
        local $Test::Builder::Level = $Test::Builder::Level + 3;

        fail "'$num' is not a number";
    };
}

1;