This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Move ExtUtils-Command to cpan/
[perl5.git] / cpan / Locale-Codes / t / language2code.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::Codes::Language;
20
21 %type = ( "LOCALE_LANG_ALPHA_2" => LOCALE_LANG_ALPHA_2,
22           "LOCALE_LANG_ALPHA_3" => LOCALE_LANG_ALPHA_3,
23           "LOCALE_LANG_TERM"    => LOCALE_LANG_TERM,
24         );
25
26 sub test {
27    my(@test) = @_;
28    $test[1]  = $type{$test[1]}
29      if (@test == 2  &&  $test[1]  &&  exists $type{$test[1]});
30    return language2code(@test);
31 }
32
33 $tests = "
34
35 Banana ~ _undef_
36
37 ~ _undef_
38
39 _undef_ ~ _undef_
40
41 Afar
42    ~
43    aa
44
45 ESTONIAN
46    ~
47    et
48
49 French
50    ~
51    fr
52
53 Greek
54    ~
55    el
56
57 Japanese
58    ~
59    ja
60
61 Zulu
62    ~
63    zu
64
65 english
66    ~
67    en
68
69 japanese
70    ~
71    ja
72
73 # Last ones in the list
74
75 Zulu
76 LOCALE_LANG_ALPHA_2
77    ~
78    zu
79
80 Zaza
81 LOCALE_LANG_ALPHA_3
82    ~
83    zza
84
85 Welsh
86 LOCALE_LANG_TERM
87    ~
88    cym
89
90 Zande languages
91 LOCALE_LANG_ALPHA_3
92    ~
93    znd
94
95 Zuojiang Zhuang
96 LOCALE_LANG_ALPHA_3
97    ~
98    zzj
99
100 ";
101
102 print "language2code...\n";
103 test_Func(\&test,$tests,$runtests);
104
105 1;
106 # Local Variables:
107 # mode: cperl
108 # indent-tabs-mode: nil
109 # cperl-indent-level: 3
110 # cperl-continued-statement-offset: 2
111 # cperl-continued-brace-offset: 0
112 # cperl-brace-offset: 0
113 # cperl-brace-imaginary-offset: 0
114 # cperl-label-offset: -2
115 # End: