Upgrade to I18N::LangTags 0.32
[p5sagit/p5-mst-13.2.git] / lib / I18N / LangTags / t / 80_all_env.t
CommitLineData
8000a3fa 1
2require 5;
3use Test;
8fcd89ec 4# Time-stamp: "2004-06-20 21:51:11 ADT"
8575f5e6 5BEGIN { plan tests => 14; }
8000a3fa 6use I18N::LangTags::Detect 1.01;
7print "# Hi there...\n";
8ok 1;
9
8575f5e6 10print "# Using I18N::LangTags::Detect v$I18N::LangTags::Detect::VERSION\n";
11
8000a3fa 12print "# 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
17delete $ENV{'MYORP'};
18delete $ENV{'SWUZ'};
19
8575f5e6 20sub j { "[" . join(' ', map "\"$_\"", @_) . "]" ;}
21
22sub show {
23 print "# (Seeing {", join(' ',
24 map(qq{<$_>}, @_)), "} at line ", (caller)[2], ")\n";
25 printenv();
26 return $_[0] || '';
27}
28sub 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
38print "# Test LANG...\n";
39$ENV{'REQUEST_METHOD'} = '';
40$ENV{'LANG'} = 'Eu_MT';
41$ENV{'LANGUAGE'} = '';
8575f5e6 42ok show( scalar I18N::LangTags::Detect::detect()), "eu-mt";
43ok show( j I18N::LangTags::Detect::detect()), q{["eu-mt"]};
8000a3fa 44
45print "# Test LANGUAGE...\n";
46$ENV{'LANG'} = '';
47$ENV{'LANGUAGE'} = 'Eu-MT';
8575f5e6 48ok show( scalar I18N::LangTags::Detect::detect()), "eu-mt";
49ok show( j I18N::LangTags::Detect::detect()), q{["eu-mt"]};
8000a3fa 50
51
52print "# Test HTTP_ACCEPT_LANGUAGE...\n";
53$ENV{'REQUEST_METHOD'} = 'GET';
54$ENV{'HTTP_ACCEPT_LANGUAGE'} = 'eu-MT';
8575f5e6 55ok show( scalar I18N::LangTags::Detect::detect()), "eu-mt";
56ok 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 60ok show( scalar I18N::LangTags::Detect::detect()), "x-plorp";
61ok 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 64ok show( scalar I18N::LangTags::Detect::detect()), "x-plorp";
65ok show( j I18N::LangTags::Detect::detect()), qq{["x-plorp" "i-plorp" "zaz" "eu-mt" "i-klung" "x-klung"]};
66
8000a3fa 67
68
69
70print "# Byebye!\n";
71ok 1;
72