File: basic.t

package info (click to toggle)
liblingua-en-inflect-number-perl 1.12-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 104 kB
  • sloc: perl: 44; makefile: 2
file content (41 lines) | stat: -rw-r--r-- 1,137 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
# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl test.pl'

#########################

# change 'tests => 1' to 'tests => last_test_to_print';

use 5.006;
use strict;
use warnings;

use Test::More tests => 21;
use Lingua::EN::Inflect::Number (qw( PL_N to_PL to_S number));

ok(*PL_N{CODE}, "Imported something from L::EN::Inflect");
ok(*to_PL{CODE}, "Imported something from Number");

is(number("goat"), "s", "one goat");
is(number("goats"), "p", "two goats");
is(number("sheep"), "ambig", "who knows how many sheep?");

test_all(@$_) for (
     [ qw(  goat goats )],
     [ qw( brewery breweries )],
     [ qw( beer beers )],
     [ qw( sheep sheep )],
 );

sub test_all {
    my ($s, $p) = @_;
    is( to_S($p), $s, "$p to singular is $s");
    is( to_S($s), $s, "$s is already singular");
    is( to_PL($s), $p, "Force $s to plural");
    is( to_PL($p), $p, "Force $p to plural");
}

#########################

# Insert your test code below, the Test module is use()ed here so read
# its man page ( perldoc Test ) for help writing this test script.