This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Remove duplicate test for $ENV{LANG} in I18N::LangTags test 80_all_env.t
[perl5.git] / dist / I18N-LangTags / t / 80_all_env.t
CommitLineData
8000a3fa
RGS
1
2require 5;
3use Test;
66ee8a1c 4# Time-stamp: "2004-07-01 14:33:50 ADT"
1d810d02 5BEGIN { plan tests => 18; }
8000a3fa
RGS
6use I18N::LangTags::Detect 1.01;
7print "# Hi there...\n";
8ok 1;
9
8575f5e6
RGS
10print "# Using I18N::LangTags::Detect v$I18N::LangTags::Detect::VERSION\n";
11
8000a3fa
RGS
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
RGS
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
66ee8a1c
RGS
38
39print "# Test LANGUAGE...\n";
40$ENV{'REQUEST_METHOD'} = '';
41$ENV{'LANGUAGE'} = 'Eu-MT';
42$ENV{'LC_ALL'} = '';
43$ENV{'LC_MESSAGES'} = '';
44$ENV{'LANG'} = '';
45ok show( scalar I18N::LangTags::Detect::detect()), "eu-mt";
46ok show( j I18N::LangTags::Detect::detect()), q{["eu-mt"]};
47
48
49print "# Test LC_ALL...\n";
50$ENV{'REQUEST_METHOD'} = '';
51$ENV{'LANGUAGE'} = '';
52$ENV{'LC_ALL'} = 'Eu-MT';
53$ENV{'LC_MESSAGES'} = '';
54$ENV{'LANG'} = '';
55
56ok show( scalar I18N::LangTags::Detect::detect()), "eu-mt";
57ok show( j I18N::LangTags::Detect::detect()), q{["eu-mt"]};
58
59print "# Test LC_MESSAGES...\n";
60$ENV{'REQUEST_METHOD'} = '';
61$ENV{'LANGUAGE'} = '';
62$ENV{'LC_ALL'} = '';
63$ENV{'LC_MESSAGES'} = 'Eu-MT';
64$ENV{'LANG'} = '';
65
66ok show( scalar I18N::LangTags::Detect::detect()), "eu-mt";
67ok show( j I18N::LangTags::Detect::detect()), q{["eu-mt"]};
68
69
8000a3fa
RGS
70print "# Test LANG...\n";
71$ENV{'REQUEST_METHOD'} = '';
66ee8a1c
RGS
72$ENV{'LANGUAGE'} = '';
73$ENV{'LC_ALL'} = '';
74$ENV{'LC_MESSAGES'} = '';
75$ENV{'LANG'} = 'Eu_MT';
76
8575f5e6
RGS
77ok show( scalar I18N::LangTags::Detect::detect()), "eu-mt";
78ok show( j I18N::LangTags::Detect::detect()), q{["eu-mt"]};
8000a3fa 79
66ee8a1c
RGS
80
81
66ee8a1c 82
8000a3fa
RGS
83print "# Test HTTP_ACCEPT_LANGUAGE...\n";
84$ENV{'REQUEST_METHOD'} = 'GET';
85$ENV{'HTTP_ACCEPT_LANGUAGE'} = 'eu-MT';
8575f5e6
RGS
86ok show( scalar I18N::LangTags::Detect::detect()), "eu-mt";
87ok show( j I18N::LangTags::Detect::detect()), q{["eu-mt"]};
88
8000a3fa
RGS
89
90$ENV{'HTTP_ACCEPT_LANGUAGE'} = 'x-plorp, zaz, eu-MT, i-klung';
8575f5e6
RGS
91ok show( scalar I18N::LangTags::Detect::detect()), "x-plorp";
92ok show( j I18N::LangTags::Detect::detect()), qq{["x-plorp" "i-plorp" "zaz" "eu-mt" "i-klung" "x-klung"]};
8000a3fa
RGS
93
94$ENV{'HTTP_ACCEPT_LANGUAGE'} = 'x-plorp, zaz, eU-Mt, i-klung';
8575f5e6
RGS
95ok show( scalar I18N::LangTags::Detect::detect()), "x-plorp";
96ok show( j I18N::LangTags::Detect::detect()), qq{["x-plorp" "i-plorp" "zaz" "eu-mt" "i-klung" "x-klung"]};
97
8000a3fa
RGS
98
99
100
101print "# Byebye!\n";
102ok 1;
103