Locale-Utils-PlaceholderBabelFish

 view release on metacpan or  search on metacpan

t/05_expand_plural.t  view on Meta::CPAN

#!perl -T

use strict;
use warnings;

use Test::More tests => 13;
use Test::NoWarnings;
use Test::Differences;
BEGIN {
    use_ok 'Locale::Utils::PlaceholderBabelFish';
}

my $obj = Locale::Utils::PlaceholderBabelFish->new;

# parameter types
eq_or_diff
    $obj->expand_babel_fish(
        '((#{count} s))',
        4234567.890,
    ),
    '4234567.89 s',
    'no strict, number';
eq_or_diff
    $obj->expand_babel_fish(
        '((#{count} s))',
        count => 4234567.890,
    ),
    '4234567.89 s',
    'no strict, hash';
eq_or_diff
    $obj->expand_babel_fish(
        '((#{count} s))',
        { count => 4234567.890 },
    ),
    '4234567.89 s',
    'no strict, hash_ref';

# broken count
eq_or_diff
    $obj->expand_babel_fish(
        '((s)):c1; ((s)):c2; ((s)):c3; ((s)):c4',
        c1 => undef,
        c2 => 'three',
        c3 => '4_234_567.890',
        c4 => 4234567.890,
    ),
    '((s)):c1; ((s)):c2; ((s)):c3; s',
    'no strict, broken count';

# plual selection
eq_or_diff
    $obj->expand_babel_fish(
        '((s|p)); ((s|p)):count0',
        count  => 1,
        count0 => 0,
    ),
    's; p',
    'no strict, plural';

# special zero
eq_or_diff
    $obj->expand_babel_fish(
        '((s|p)); ((=0 z|s|p))',
        0,
    ),
    'p; z',
    'no strict, special zero';



( run in 1.070 second using v1.01-cache-2.11-cpan-5735350b133 )