Locale-TextDomain-OO

 view release on metacpan or  search on metacpan

t/41_tied_interface.t  view on Meta::CPAN

#!perl -T

use strict;
use warnings;

use Test::More tests => 27;
use Test::NoWarnings;
use Test::Exception;
use Test::Differences;

BEGIN {
    require_ok('Locale::TextDomain::OO');
    require_ok('Locale::TextDomain::OO::Lexicon::File::MO');
    require_ok('Locale::TextDomain::OO::TiedInterface');
    Locale::TextDomain::OO::TiedInterface->import;
}

throws_ok
    sub {
        Locale::TextDomain::OO::TiedInterface->import(undef);
    },
    qr{\A \QAn undefined value is not a variable name}xms,
    'tie object method with an undefined method name';
throws_ok
    sub {
        Locale::TextDomain::OO::TiedInterface->import('__');
    },
    qr{\A \Q"__" is not a hash or a hash reference}xms,
    'tie __ failed';
throws_ok
    sub {
        Locale::TextDomain::OO::TiedInterface->import('$__y');
    },
    qr{\A "\$__y"\Q is not exported}xms,
    'tie $__y failed';

${$loc_ref} = Locale::TextDomain::OO->new(
    language => 'de',
    domain   => 'test',
    category => 'LC_MESSAGES',
    logger   => sub { note shift },
    plugins  => [ qw(
        Expand::Gettext::DomainAndCategory
        Expand::Maketext
    ) ],
);

Locale::TextDomain::OO::Lexicon::File::MO
    ->new(
        logger => sub { note shift },
    )
    ->lexicon_ref({
        search_dirs => [ './t/LocaleData' ],
        decode      => 1,
        data        => [
            '*:LC_MESSAGES:test'          => '*/LC_MESSAGES/test.mo',
            '*:LC_MESSAGES:test_maketext' => '*/LC_MESSAGES/test_maketext.mo',
        ],
    });

# gettext
is
    $__{'This is a text.'},
    'Das ist ein Text.',
    '%__';
is
    $__->{'This is a text.'},
    'Das ist ein Text.',
    '$__';



( run in 0.810 second using v1.01-cache-2.11-cpan-39bf76dae61 )