Locale-Utils-PlaceholderMaketext

 view release on metacpan or  search on metacpan

t/22_expand_gettext.t  view on Meta::CPAN

#!perl -T

use strict;
use warnings;

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

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

is_deeply
    [ $obj->expand_gettext(undef) ],
    [ undef ],
    'undef';

eq_or_diff
    $obj->expand_gettext(
        '%1;%quant(%2,s);%quant(%3,s,p);%quant(%4,s,p,z)',
        undef,
        undef,
        'three',
        '4_234_567.890',
    ),
    ';0 s;0 p;z',
    'no strict array';

eq_or_diff
    $obj->expand_gettext(
        '%1;%quant(%2,s);%quant(%3,s,p);%quant(%4,s,p,z)',
        [
            undef,
            undef,
            'three',
            '4_234_567.890',
        ],
    ),
    ';0 s;0 p;z',
    'no strict array_ref';
$obj->space(q{x});

eq_or_diff
    $obj->expand_gettext(
        '%quant(%1,s);%quant(%2,s,p)',
        1,
        2,
    ),
    '1xs;2xp',
    'space is x';

$obj->reset_space;
$obj->is_strict(1);

$obj->formatter_code(
    sub {
        my ($value, $type) = @_;

        $type eq 'numeric'
            or return $value;
        while ( $value =~ s{(\d+) (\d{3})}{$1,$2}xms ) {}
        $value =~ tr{.,}{,.};

        return $value;
    }
);



( run in 1.016 second using v1.01-cache-2.11-cpan-ceb78f64989 )