Debian Codegraph @

t/basic.t

raw
1 #!/usr/bin/env perl
2 use strict;
3 use warnings;
4
5 use Test::More;
6 use Test::Fatal 'exception';
7
8 use Lingua::EN::Number::IsOrdinal ();
9
10 use lib 't/lib';
11 use TestOrdinal qw/is_ordinal is_not_ordinal/;
12
13 # ordinal numbers as words
14
15 is_ordinal 'first';
16 is_ordinal ' second ';
17 is_ordinal 'one hundred twenty third';
18 is_ordinal 'two hundred eleventh';
19
20 # ordinal numbers as digits
21
22 is_ordinal ' 1st ';
23 is_ordinal '2nd';
24 is_ordinal '5643rd';
25
26 # cardinal numbers as words
27
28 is_not_ordinal 'one';
29 is_not_ordinal 'two';
30 is_not_ordinal 'three';
31 is_not_ordinal 'one thousand one hundred and twenty two';
32
33 # cardinal numbers as digits
34
35 is_not_ordinal '1.005';
36 is_not_ordinal '10e6';
37 is_not_ordinal '10E6';
38 is_not_ordinal '1';
39 is_not_ordinal '2';
40 is_not_ordinal '3';
41 is_not_ordinal '234254345';
42
43 # checking for numbers
44
45 like(
46 exception { Lingua::EN::Number::IsOrdinal::is_ordinal('cheese') },
47 qr/not a number/,
48 'throws on not a number',
49 );
50
51 done_testing;