Commit | Line | Data |
---|---|---|
f666394a | 1 | #!/usr/bin/perl -Tw |
f918d677 | 2 | |
f666394a RGS |
3 | use strict; |
4 | use Test::More tests => 10; | |
5 | ||
6 | BEGIN { | |
7 | use_ok( 'Locale::Maketext' ); | |
8 | } | |
f918d677 JH |
9 | |
10 | print "# --- Making sure that get_handle works ---\n"; | |
11 | ||
12 | # declare some classes... | |
13 | { | |
f666394a RGS |
14 | package Woozle; |
15 | our @ISA = ('Locale::Maketext'); | |
16 | sub dubbil { return $_[1] * 2 } | |
17 | sub numerate { return $_[2] . 'en' } | |
f918d677 JH |
18 | } |
19 | { | |
f666394a RGS |
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 | |
f918d677 JH |
28 | } |
29 | ||
f666394a RGS |
30 | my $lh = Woozle->get_handle('eu-mt'); |
31 | isa_ok( $lh, 'Woozle::eu_mt' ); | |
32 | is( $lh->maketext( 'd2', 7 ), 'hum 14' ); | |
f918d677 JH |
33 | |
34 | print "# Make sure we can assign to ENV entries\n", | |
f666394a | 35 | "# (Otherwise we can't run the subsequent tests)...\n"; |
f918d677 | 36 | $ENV{'MYORP'} = 'Zing'; |
f666394a | 37 | is( $ENV{'MYORP'}, 'Zing' ); |
f918d677 | 38 | $ENV{'SWUZ'} = 'KLORTHO HOOBOY'; |
f666394a | 39 | is( $ENV{'SWUZ'}, 'KLORTHO HOOBOY' ); |
f918d677 JH |
40 | |
41 | delete $ENV{'MYORP'}; | |
42 | delete $ENV{'SWUZ'}; | |
43 | ||
1189c245 | 44 | |
f918d677 | 45 | print "# Test LANG...\n"; |
1189c245 RGS |
46 | $ENV{'LC_ALL'} = ''; |
47 | $ENV{'LC_MESSAGES'} = ''; | |
f918d677 JH |
48 | $ENV{'REQUEST_METHOD'} = ''; |
49 | $ENV{'LANG'} = 'Eu_MT'; | |
50 | $ENV{'LANGUAGE'} = ''; | |
f666394a RGS |
51 | $lh = Woozle->get_handle(); |
52 | isa_ok( $lh, 'Woozle::eu_mt' ); | |
f918d677 JH |
53 | |
54 | print "# Test LANGUAGE...\n"; | |
55 | $ENV{'LANG'} = ''; | |
56 | $ENV{'LANGUAGE'} = 'Eu-MT'; | |
f666394a RGS |
57 | $lh = Woozle->get_handle(); |
58 | isa_ok( $lh, 'Woozle::eu_mt' ); | |
f918d677 JH |
59 | |
60 | print "# Test HTTP_ACCEPT_LANGUAGE...\n"; | |
61 | $ENV{'REQUEST_METHOD'} = 'GET'; | |
62 | $ENV{'HTTP_ACCEPT_LANGUAGE'} = 'eu-MT'; | |
f666394a RGS |
63 | $lh = Woozle->get_handle(); |
64 | isa_ok( $lh, 'Woozle::eu_mt' ); | |
f918d677 | 65 | |
f666394a RGS |
66 | $ENV{'HTTP_ACCEPT_LANGUAGE'} = 'x-plorp, zaz, eu-MT, i-klung'; |
67 | $lh = Woozle->get_handle(); | |
68 | isa_ok( $lh, 'Woozle::eu_mt' ); | |
f918d677 | 69 | |
f666394a RGS |
70 | $ENV{'HTTP_ACCEPT_LANGUAGE'} = 'x-plorp, zaz, eU-Mt, i-klung'; |
71 | $lh = Woozle->get_handle(); | |
72 | isa_ok( $lh, 'Woozle::eu_mt' ); |