Commit | Line | Data |
8000a3fa |
1 | |
2 | require 5; |
3 | use Test; |
8fcd89ec |
4 | # Time-stamp: "2004-06-20 21:51:11 ADT" |
8575f5e6 |
5 | BEGIN { plan tests => 14; } |
8000a3fa |
6 | use I18N::LangTags::Detect 1.01; |
7 | print "# Hi there...\n"; |
8 | ok 1; |
9 | |
8575f5e6 |
10 | print "# Using I18N::LangTags::Detect v$I18N::LangTags::Detect::VERSION\n"; |
11 | |
8000a3fa |
12 | print "# Make sure we can assign to ENV entries\n", |
13 | "# (Otherwise we can't run the subsequent tests)...\n"; |
14 | $ENV{'MYORP'} = 'Zing'; ok $ENV{'MYORP'}, 'Zing'; |
15 | $ENV{'SWUZ'} = 'KLORTHO HOOBOY'; ok $ENV{'SWUZ'}, 'KLORTHO HOOBOY'; |
16 | |
17 | delete $ENV{'MYORP'}; |
18 | delete $ENV{'SWUZ'}; |
19 | |
8575f5e6 |
20 | sub j { "[" . join(' ', map "\"$_\"", @_) . "]" ;} |
21 | |
22 | sub show { |
23 | print "# (Seeing {", join(' ', |
24 | map(qq{<$_>}, @_)), "} at line ", (caller)[2], ")\n"; |
25 | printenv(); |
26 | return $_[0] || ''; |
27 | } |
28 | sub printenv { |
29 | print "# ENV:\n"; |
30 | foreach my $k (sort keys %ENV) { |
31 | my $p = $ENV{$k}; $p =~ s/\n/\n#/g; |
32 | print "# [$k] = [$p]\n"; } |
33 | print "# [end of ENV]\n#\n"; |
34 | } |
35 | |
8fcd89ec |
36 | $ENV{'IGNORE_WIN32_LOCALE'} = 1; # a hack, just for testing's sake. |
8000a3fa |
37 | |
38 | print "# Test LANG...\n"; |
39 | $ENV{'REQUEST_METHOD'} = ''; |
40 | $ENV{'LANG'} = 'Eu_MT'; |
41 | $ENV{'LANGUAGE'} = ''; |
8575f5e6 |
42 | ok show( scalar I18N::LangTags::Detect::detect()), "eu-mt"; |
43 | ok show( j I18N::LangTags::Detect::detect()), q{["eu-mt"]}; |
8000a3fa |
44 | |
45 | print "# Test LANGUAGE...\n"; |
46 | $ENV{'LANG'} = ''; |
47 | $ENV{'LANGUAGE'} = 'Eu-MT'; |
8575f5e6 |
48 | ok show( scalar I18N::LangTags::Detect::detect()), "eu-mt"; |
49 | ok show( j I18N::LangTags::Detect::detect()), q{["eu-mt"]}; |
8000a3fa |
50 | |
51 | |
52 | print "# Test HTTP_ACCEPT_LANGUAGE...\n"; |
53 | $ENV{'REQUEST_METHOD'} = 'GET'; |
54 | $ENV{'HTTP_ACCEPT_LANGUAGE'} = 'eu-MT'; |
8575f5e6 |
55 | ok show( scalar I18N::LangTags::Detect::detect()), "eu-mt"; |
56 | ok show( j I18N::LangTags::Detect::detect()), q{["eu-mt"]}; |
57 | |
8000a3fa |
58 | |
59 | $ENV{'HTTP_ACCEPT_LANGUAGE'} = 'x-plorp, zaz, eu-MT, i-klung'; |
8575f5e6 |
60 | ok show( scalar I18N::LangTags::Detect::detect()), "x-plorp"; |
61 | ok show( j I18N::LangTags::Detect::detect()), qq{["x-plorp" "i-plorp" "zaz" "eu-mt" "i-klung" "x-klung"]}; |
8000a3fa |
62 | |
63 | $ENV{'HTTP_ACCEPT_LANGUAGE'} = 'x-plorp, zaz, eU-Mt, i-klung'; |
8575f5e6 |
64 | ok show( scalar I18N::LangTags::Detect::detect()), "x-plorp"; |
65 | ok show( j I18N::LangTags::Detect::detect()), qq{["x-plorp" "i-plorp" "zaz" "eu-mt" "i-klung" "x-klung"]}; |
66 | |
8000a3fa |
67 | |
68 | |
69 | |
70 | print "# Byebye!\n"; |
71 | ok 1; |
72 | |