File: 01inflect.t

package info (click to toggle)
libtemplate-plugin-lingua-en-inflect-perl 0.04-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 128 kB
  • sloc: perl: 236; makefile: 2
file content (97 lines) | stat: -rw-r--r-- 1,865 bytes parent folder | download | duplicates (3)
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/usr/bin/perl -w
use strict;

use Template::Test;

test_expect(\*DATA);

__END__
--test--
[%- # testing inflect filter with a block
    USE Lingua.EN.Inflect;
    FILTER inflect(number => 42); -%]
There PL_V(was) NO(error).
PL_ADJ(This) PL_N(error) PL_V(was) fatal.
[%
    END;
 -%]
--expect--
There were 42 errors.
These errors were fatal.

--test--
[% USE Lingua.EN.Inflect -%]
[% "NUM(3) PL_N(error)." | inflect -%]
--expect--
3 errors.

--test--
[% USE i = Lingua.EN.Inflect -%]
[% "NUM(0,0)There PL_V(was) NO(error)." | inflect -%]
--expect--
There were no errors.

--test--
[%- # testing inflect
    USE inflect = Lingua.EN.Inflect;
    "NUM(0,0)There PL_V(was) NO(error)." | inflect;
-%]
--expect--
There were no errors.

--test--
[%  # testing inflect
    USE Lingua.EN.Inflect;
    "NUM(1,0)There PL_V(was) NO(error)." | inflect;
 -%]
--expect--
There was 1 error.

--test--
[%- # testing inflect
    USE Lingua.EN.Inflect;
    "NUM(3,0)There PL_V(was) NO(error)." | inflect;
 -%]
--expect--
There were 3 errors.

--test--
[%- # testing inflect
    USE Lingua.EN.Inflect;
    "There PL_V(was) NO(error)." | inflect(number => 5);
 -%]
--expect--
There were 5 errors.

--test--
[%  # testing NO()
    USE i = Lingua.EN.Inflect;
    FOREACH n IN [ 0, 1, 2, 3, 42 ];
        i.NO('cat', n);
        ', ' UNLESS loop.last;
    END;
 -%]
--expect--
no cats, 1 cat, 2 cats, 3 cats, 42 cats

--test--
[%  # testing NUMWORDS() for 1, 2, 3, ...
    USE i = Lingua.EN.Inflect;
    FOREACH n IN [ 1, 2, 3, 4, 42, 1000 ];
        i.NUMWORDS(n);
        ', ' UNLESS loop.last;
    END;
 -%]
--expect--
one, two, three, four, forty-two, one thousand

--test--
[%  # testing ORD()
    USE Lingua.EN.Inflect;
    FOREACH n IN [ 1, 2, 3, 4, 5, 100 ];
        Lingua.EN.Inflect.ORD(n);
        ', ' UNLESS loop.last;
    END;
 -%]
--expect--
1st, 2nd, 3rd, 4th, 5th, 100th