This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Upgrade to Locale::Codes 2.02.
[perl5.git] / lib / Locale / Codes / t / currency.t
CommitLineData
47a334e9
JH
1#!./perl
2#
3# currency.t - tests for Locale::Currency
4#
a8135056
JH
5
6BEGIN {
7 chdir 't' if -d 't';
8 @INC = '../lib';
9}
10
47a334e9
JH
11use Locale::Currency;
12
13#-----------------------------------------------------------------------
14# This is an array of tests. Each test is eval'd as an expression.
15# If it evaluates to FALSE, then "not ok N" is printed for the test,
16# otherwise "ok N".
17#-----------------------------------------------------------------------
18@TESTS =
19(
20 #================================================
21 # TESTS FOR code2currency
22 #================================================
23
24 #---- selection of examples which should all result in undef -----------
25 '!defined code2currency()', # no argument => undef returned
26 '!defined code2currency(undef)', # undef arg => undef returned
27 '!defined code2currency("zz")', # illegal code => undef
28 '!defined code2currency("zzzz")', # illegal code => undef
29 '!defined code2currency("zzz")', # illegal code => undef
30 '!defined code2currency("ukp")', # gbp for sterling, not ukp
31
32 #---- misc tests -------------------------------------------------------
33 'code2currency("all") eq "Lek"',
34 'code2currency("ats") eq "Schilling"',
35 'code2currency("bob") eq "Boliviano"',
36 'code2currency("bnd") eq "Brunei Dollar"',
37 'code2currency("cop") eq "Colombian Peso"',
38 'code2currency("dkk") eq "Danish Krone"',
39 'code2currency("fjd") eq "Fiji Dollar"',
40 'code2currency("idr") eq "Rupiah"',
41 'code2currency("chf") eq "Swiss Franc"',
42 'code2currency("mvr") eq "Rufiyaa"',
43 'code2currency("mmk") eq "Kyat"',
44 'code2currency("mwk") eq "Kwacha"', # two different codes for Kwacha
45 'code2currency("zmk") eq "Kwacha"', # used in Zambia and Malawi
46 'code2currency("byr") eq "Belarussian Ruble"', # 2 codes for belarussian ruble
47 'code2currency("byb") eq "Belarussian Ruble"', #
48 'code2currency("rub") eq "Russian Ruble"', # 2 codes for russian ruble
49 'code2currency("rur") eq "Russian Ruble"', #
50
51 #---- some successful examples -----------------------------------------
52 'code2currency("BOB") eq "Boliviano"',
53 'code2currency("adp") eq "Andorran Peseta"', # first in DATA segment
54 'code2currency("zwd") eq "Zimbabwe Dollar"', # last in DATA segment
55
56 #================================================
57 # TESTS FOR currency2code
58 #================================================
59
60 #---- selection of examples which should all result in undef -----------
61 '!defined currency2code()', # no argument => undef returned
62 '!defined currency2code(undef)', # undef arg => undef returned
63 '!defined currency2code("")', # empty string => undef returned
64 '!defined currency2code("Banana")', # illegal curr name => undef
65
66 #---- some successful examples -----------------------------------------
67 'currency2code("Kroon") eq "eek"',
68 'currency2code("Markka") eq "fim"',
69 'currency2code("Riel") eq "khr"',
70 'currency2code("PULA") eq "bwp"',
71 'currency2code("Andorran Peseta") eq "adp"', # first in DATA segment
72 'currency2code("Zimbabwe Dollar") eq "zwd"', # last in DATA segment
73);
74
75print "1..", int(@TESTS), "\n";
76
77$testid = 1;
78foreach $test (@TESTS)
79{
80 eval "print (($test) ? \"ok $testid\\n\" : \"not ok $testid\\n\" )";
81 print "not ok $testid\n" if $@;
82 ++$testid;
83}
84
85exit 0;