Blame t/20_get.t

Packit f92f8e
#!/usr/bin/perl -Tw
Packit f92f8e
Packit f92f8e
use strict;
Packit f92f8e
use Test::More tests => 10;
Packit f92f8e
Packit f92f8e
BEGIN {
Packit f92f8e
    use_ok( 'Locale::Maketext' );
Packit f92f8e
}
Packit f92f8e
Packit f92f8e
print "# --- Making sure that get_handle works ---\n";
Packit f92f8e
Packit f92f8e
# declare some classes...
Packit f92f8e
{
Packit f92f8e
    package Woozle;
Packit f92f8e
    our @ISA = ('Locale::Maketext');
Packit f92f8e
    sub dubbil   { return $_[1] * 2 }
Packit f92f8e
    sub numerate { return $_[2] . 'en' }
Packit f92f8e
}
Packit f92f8e
{
Packit f92f8e
    package Woozle::eu_mt;
Packit f92f8e
    our @ISA = ('Woozle');
Packit f92f8e
    our %Lexicon = (
Packit f92f8e
        'd2' => 'hum [dubbil,_1]',
Packit f92f8e
        'd3' => 'hoo [quant,_1,zaz]',
Packit f92f8e
        'd4' => 'hoo [*,_1,zaz]',
Packit f92f8e
    );
Packit f92f8e
    keys %Lexicon; # dodges the 'used only once' warning
Packit f92f8e
}
Packit f92f8e
Packit f92f8e
my $lh = Woozle->get_handle('eu-mt');
Packit f92f8e
isa_ok( $lh, 'Woozle::eu_mt' );
Packit f92f8e
is( $lh->maketext( 'd2', 7 ), 'hum 14' );
Packit f92f8e
Packit f92f8e
print "# Make sure we can assign to ENV entries\n",
Packit f92f8e
"# (Otherwise we can't run the subsequent tests)...\n";
Packit f92f8e
$ENV{'MYORP'}   = 'Zing';
Packit f92f8e
is( $ENV{'MYORP'}, 'Zing' );
Packit f92f8e
$ENV{'SWUZ'}   = 'KLORTHO HOOBOY';
Packit f92f8e
is( $ENV{'SWUZ'}, 'KLORTHO HOOBOY' );
Packit f92f8e
Packit f92f8e
delete $ENV{'MYORP'};
Packit f92f8e
delete $ENV{'SWUZ'};
Packit f92f8e
Packit f92f8e
Packit f92f8e
print "# Test LANG...\n";
Packit f92f8e
$ENV{'LC_ALL'} = '';
Packit f92f8e
$ENV{'LC_MESSAGES'} = '';
Packit f92f8e
$ENV{'REQUEST_METHOD'} = '';
Packit f92f8e
$ENV{'LANG'}     = 'Eu_MT';
Packit f92f8e
$ENV{'LANGUAGE'} = '';
Packit f92f8e
$lh = Woozle->get_handle();
Packit f92f8e
isa_ok( $lh, 'Woozle::eu_mt' );
Packit f92f8e
Packit f92f8e
print "# Test LANGUAGE...\n";
Packit f92f8e
$ENV{'LANG'}     = '';
Packit f92f8e
$ENV{'LANGUAGE'} = 'Eu-MT';
Packit f92f8e
$lh = Woozle->get_handle();
Packit f92f8e
isa_ok( $lh, 'Woozle::eu_mt' );
Packit f92f8e
Packit f92f8e
print "# Test HTTP_ACCEPT_LANGUAGE...\n";
Packit f92f8e
$ENV{'REQUEST_METHOD'}       = 'GET';
Packit f92f8e
$ENV{'HTTP_ACCEPT_LANGUAGE'} = 'eu-MT';
Packit f92f8e
$lh = Woozle->get_handle();
Packit f92f8e
isa_ok( $lh, 'Woozle::eu_mt' );
Packit f92f8e
Packit f92f8e
$ENV{'HTTP_ACCEPT_LANGUAGE'} = 'x-plorp, zaz, eu-MT, i-klung';
Packit f92f8e
$lh = Woozle->get_handle();
Packit f92f8e
isa_ok( $lh, 'Woozle::eu_mt' );
Packit f92f8e
Packit f92f8e
$ENV{'HTTP_ACCEPT_LANGUAGE'} = 'x-plorp, zaz, eU-Mt, i-klung';
Packit f92f8e
$lh = Woozle->get_handle();
Packit f92f8e
isa_ok( $lh, 'Woozle::eu_mt' );