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