Update Locale::Codes to 3.12
[p5sagit/p5-mst-13.2.git] / cpan / Locale-Codes / t / alias_code.t
1 #!/usr/bin/perl -w
2
3 require 5.002;
4
5 $runtests=shift(@ARGV);
6 if ( -f "t/testfunc.pl" ) {
7   require "t/testfunc.pl";
8   $dir="./lib";
9   $tdir="t";
10 } elsif ( -f "testfunc.pl" ) {
11   require "testfunc.pl";
12   $dir="../lib";
13   $tdir=".";
14 } else {
15   die "ERROR: cannot find testfunc.pl\n";
16 }
17
18 unshift(@INC,$dir);
19 use Locale::Country;
20
21 %type = ( "LOCALE_CODE_ALPHA_2" => LOCALE_CODE_ALPHA_2,
22           "LOCALE_CODE_ALPHA_3" => LOCALE_CODE_ALPHA_3,
23           "LOCALE_CODE_NUMERIC" => LOCALE_CODE_NUMERIC,
24         );
25
26 sub test {
27    my(@test) = @_;
28
29    if ($test[0] eq "alias_code") {
30       shift(@test);
31       $test[2]  = $type{$test[2]}
32         if (@test == 3  &&  $test[2]  &&  exists $type{$test[2]});
33       return Locale::Country::alias_code(@test,"nowarn");
34
35    } elsif ($test[0] eq "country2code") {
36       shift(@test);
37       $test[1]  = $type{$test[1]}   if (@test == 2  &&  $test[1]  &&  exists $type{$test[1]});
38       return country2code(@test);
39
40    } else {
41       $test[1]  = $type{$test[1]}
42         if (@test == 2  &&  $test[1]  &&  exists $type{$test[1]});
43       return code2country(@test);
44    }
45 }
46
47 $tests = "
48
49 gb
50    ~
51    United Kingdom
52
53 uk
54    ~
55    _undef_
56
57 country2code
58 United Kingdom
59    ~
60    gb
61
62 alias_code uk gb LOCALE_CODE_FOO ~ 0
63
64 alias_code uk x1 ~ 0
65
66 alias_code us gb ~ 0
67
68 alias_code uk gb LOCALE_CODE_ALPHA_3 ~ 0
69
70 gb
71    ~
72    United Kingdom
73
74 uk
75    ~
76    _undef_
77
78 country2code
79 United Kingdom
80    ~
81    gb
82
83 alias_code uk gb ~ uk
84
85 gb
86    ~
87    United Kingdom
88
89 uk
90    ~
91    United Kingdom
92
93 country2code
94 United Kingdom
95    ~
96    uk
97
98 ";
99
100 print "alias_code...\n";
101 test_Func(\&test,$tests,$runtests);
102
103 1;
104 # Local Variables:
105 # mode: cperl
106 # indent-tabs-mode: nil
107 # cperl-indent-level: 3
108 # cperl-continued-statement-offset: 2
109 # cperl-continued-brace-offset: 0
110 # cperl-brace-offset: 0
111 # cperl-brace-imaginary-offset: 0
112 # cperl-label-offset: -2
113 # End: