Move Locale::Maketext from ext/ to dist/
[p5sagit/p5-mst-13.2.git] / dist / Locale-Maketext / t / 20_get.t
1 #!/usr/bin/perl -Tw
2
3 use strict;
4 use Test::More tests => 10;
5
6 BEGIN {
7     use_ok( 'Locale::Maketext' );
8 }
9
10 print "# --- Making sure that get_handle works ---\n";
11
12 # declare some classes...
13 {
14     package Woozle;
15     our @ISA = ('Locale::Maketext');
16     sub dubbil   { return $_[1] * 2 }
17     sub numerate { return $_[2] . 'en' }
18 }
19 {
20     package Woozle::eu_mt;
21     our @ISA = ('Woozle');
22     our %Lexicon = (
23         'd2' => 'hum [dubbil,_1]',
24         'd3' => 'hoo [quant,_1,zaz]',
25         'd4' => 'hoo [*,_1,zaz]',
26     );
27     keys %Lexicon; # dodges the 'used only once' warning
28 }
29
30 my $lh = Woozle->get_handle('eu-mt');
31 isa_ok( $lh, 'Woozle::eu_mt' );
32 is( $lh->maketext( 'd2', 7 ), 'hum 14' );
33
34 print "# Make sure we can assign to ENV entries\n",
35 "# (Otherwise we can't run the subsequent tests)...\n";
36 $ENV{'MYORP'}   = 'Zing';
37 is( $ENV{'MYORP'}, 'Zing' );
38 $ENV{'SWUZ'}   = 'KLORTHO HOOBOY';
39 is( $ENV{'SWUZ'}, 'KLORTHO HOOBOY' );
40
41 delete $ENV{'MYORP'};
42 delete $ENV{'SWUZ'};
43
44
45 print "# Test LANG...\n";
46 $ENV{'LC_ALL'} = '';
47 $ENV{'LC_MESSAGES'} = '';
48 $ENV{'REQUEST_METHOD'} = '';
49 $ENV{'LANG'}     = 'Eu_MT';
50 $ENV{'LANGUAGE'} = '';
51 $lh = Woozle->get_handle();
52 isa_ok( $lh, 'Woozle::eu_mt' );
53
54 print "# Test LANGUAGE...\n";
55 $ENV{'LANG'}     = '';
56 $ENV{'LANGUAGE'} = 'Eu-MT';
57 $lh = Woozle->get_handle();
58 isa_ok( $lh, 'Woozle::eu_mt' );
59
60 print "# Test HTTP_ACCEPT_LANGUAGE...\n";
61 $ENV{'REQUEST_METHOD'}       = 'GET';
62 $ENV{'HTTP_ACCEPT_LANGUAGE'} = 'eu-MT';
63 $lh = Woozle->get_handle();
64 isa_ok( $lh, 'Woozle::eu_mt' );
65
66 $ENV{'HTTP_ACCEPT_LANGUAGE'} = 'x-plorp, zaz, eu-MT, i-klung';
67 $lh = Woozle->get_handle();
68 isa_ok( $lh, 'Woozle::eu_mt' );
69
70 $ENV{'HTTP_ACCEPT_LANGUAGE'} = 'x-plorp, zaz, eU-Mt, i-klung';
71 $lh = Woozle->get_handle();
72 isa_ok( $lh, 'Woozle::eu_mt' );