diff options
Diffstat (limited to 'lib/Locale/Codes')
-rw-r--r-- | lib/Locale/Codes/ChangeLog | 9 | ||||
-rw-r--r-- | lib/Locale/Codes/README | 2 | ||||
-rw-r--r-- | lib/Locale/Codes/t/rename.t | 79 | ||||
-rw-r--r-- | lib/Locale/Codes/t/uk.t | 2 |
4 files changed, 90 insertions, 2 deletions
diff --git a/lib/Locale/Codes/ChangeLog b/lib/Locale/Codes/ChangeLog index 639e6319b3..e77140b4df 100644 --- a/lib/Locale/Codes/ChangeLog +++ b/lib/Locale/Codes/ChangeLog @@ -1,6 +1,15 @@ ChangeLog for Locale-Codes Distribution +2.02 2002-03-09 neilb + + * added semi-private routine rename_country() to Locale::Country, + based on a patch from Iain Chalmers. + * added test rename.t for the above function. + * renamed _alias_code to be alias_code. Have retained the old + name for backwards compatibility. Will remove it when the + major version number next changes. + 2.01 2002-02-18 neilb * Split the documentation for all modules into separate pod files. diff --git a/lib/Locale/Codes/README b/lib/Locale/Codes/README index 917b2c5b02..4bdd2183dd 100644 --- a/lib/Locale/Codes/README +++ b/lib/Locale/Codes/README @@ -1,6 +1,6 @@ Locale-Codes Distribution - v2.01 + v2.02 This distribution contains four Perl modules which can be used to process ISO codes for identifying languages, countries, scripts, diff --git a/lib/Locale/Codes/t/rename.t b/lib/Locale/Codes/t/rename.t new file mode 100644 index 0000000000..27f506c84b --- /dev/null +++ b/lib/Locale/Codes/t/rename.t @@ -0,0 +1,79 @@ +#!./perl +# +# rename.t - tests for Locale::Country with "uk" aliases to "gb" +# + +use Locale::Country; + +local $SIG{__WARN__} = sub { }; # muffle warnings from carp + +Locale::Country::rename_country('gb' => 'Great Britain'); + +#----------------------------------------------------------------------- +# This is an array of tests. Each test is eval'd as an expression. +# If it evaluates to FALSE, then "not ok N" is printed for the test, +# otherwise "ok N". +#----------------------------------------------------------------------- +@TESTS = +( + #================================================ + # TESTS FOR code2country + #================================================ + + #---- selection of examples which should all result in undef ----------- + '!defined code2country()', # no argument + '!defined code2country(undef)', # undef argument + '!defined code2country("zz")', # illegal code + '!defined code2country("ja")', # should be jp for country + '!defined code2country("uk")', # code for United Kingdom is 'gb' + + #---- this call should return 0, since code doesn't exist -------------- + '!Locale::Country::rename_country("ukz", "United Karz")', + + #---- some successful examples ----------------------------------------- + 'code2country("BO") eq "Bolivia"', + 'code2country("pk") eq "Pakistan"', + 'code2country("sn") eq "Senegal"', + 'code2country("us") eq "United States"', + 'code2country("ad") eq "Andorra"', # first in DATA segment + 'code2country("zw") eq "Zimbabwe"', # last in DATA segment + 'code2country("gb") eq "Great Britain"', # normally "United Kingdom" + + #================================================ + # TESTS FOR country2code + #================================================ + + #---- selection of examples which should all result in undef ----------- + '!defined country2code()', # no argument + '!defined country2code(undef)', # undef argument + '!defined country2code("Banana")', # illegal country name + + #---- some successful examples ----------------------------------------- + 'country2code("japan") eq "jp"', + 'country2code("japan") ne "ja"', + 'country2code("Japan") eq "jp"', + 'country2code("United States") eq "us"', + + 'country2code("Great Britain") eq "gb"', + 'country2code("Great Britain", LOCALE_CODE_ALPHA_3) eq "gbr"', + 'country2code("Great Britain", LOCALE_CODE_NUMERIC) eq "826"', + + 'country2code("United Kingdom") eq "gb"', + 'country2code("United Kingdom", LOCALE_CODE_ALPHA_3) eq "gbr"', + 'country2code("United Kingdom", LOCALE_CODE_NUMERIC) eq "826"', + + 'country2code("Andorra") eq "ad"', # first in DATA segment + 'country2code("Zimbabwe") eq "zw"', # last in DATA segment +); + +print "1..", int(@TESTS), "\n"; + +$testid = 1; +foreach $test (@TESTS) +{ + eval "print (($test) ? \"ok $testid\\n\" : \"not ok $testid\\n\" )"; + print "not ok $testid\n" if $@; + ++$testid; +} + +exit 0; diff --git a/lib/Locale/Codes/t/uk.t b/lib/Locale/Codes/t/uk.t index 948e2d1af2..ceca3721b5 100644 --- a/lib/Locale/Codes/t/uk.t +++ b/lib/Locale/Codes/t/uk.t @@ -10,7 +10,7 @@ BEGIN { use Locale::Country; -Locale::Country::_alias_code('uk' => 'gb'); +Locale::Country::alias_code('uk' => 'gb'); #----------------------------------------------------------------------- # This is an array of tests. Each test is eval'd as an expression. |