r73873 - in /branches/upstream/liblocale-subcountry-perl/current: Changes META.yml README lib/Locale/SubCountry.pm lib/Locale/SubCountry/Data.pm t/main.t

carnil at users.alioth.debian.org carnil at users.alioth.debian.org
Sat Apr 30 20:09:11 UTC 2011


Author: carnil
Date: Sat Apr 30 20:08:00 2011
New Revision: 73873

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=73873
Log:
[svn-upgrade] new version liblocale-subcountry-perl (1.47)

Modified:
    branches/upstream/liblocale-subcountry-perl/current/Changes
    branches/upstream/liblocale-subcountry-perl/current/META.yml
    branches/upstream/liblocale-subcountry-perl/current/README
    branches/upstream/liblocale-subcountry-perl/current/lib/Locale/SubCountry.pm
    branches/upstream/liblocale-subcountry-perl/current/lib/Locale/SubCountry/Data.pm
    branches/upstream/liblocale-subcountry-perl/current/t/main.t

Modified: branches/upstream/liblocale-subcountry-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/liblocale-subcountry-perl/current/Changes?rev=73873&op=diff
==============================================================================
--- branches/upstream/liblocale-subcountry-perl/current/Changes (original)
+++ branches/upstream/liblocale-subcountry-perl/current/Changes Sat Apr 30 20:08:00 2011
@@ -1,4 +1,15 @@
 Revision history for Perl CPAN module Locale::SubCountry
+
+1.47 29 Apr 2011
+    Converted tests to use Test::Simple in main.t
+    Added test for regional_division 
+    Added test for initialising with 2 letter country code
+    Improved synopsis
+    
+    Fixed typo in 'new' method that was stopping the use of 2 letter country codes
+    being used as a parameter. Note, this also caused a faliure in the tests for
+    the dependant module, Lingua::EN::AddressParse
+    
 
 1.46 6 Apr 2011
     Fixed main.t so tests now use title cased country names.

Modified: branches/upstream/liblocale-subcountry-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/liblocale-subcountry-perl/current/META.yml?rev=73873&op=diff
==============================================================================
--- branches/upstream/liblocale-subcountry-perl/current/META.yml (original)
+++ branches/upstream/liblocale-subcountry-perl/current/META.yml Sat Apr 30 20:08:00 2011
@@ -1,6 +1,6 @@
 --- #YAML:1.0
 name:               Locale-SubCountry
-version:            1.46
+version:            1.47
 abstract:           convert state, province, county ... names to/from ISO 3166-2 code
 author:
     - Kim Ryan <kimryan at cpan org>

Modified: branches/upstream/liblocale-subcountry-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/liblocale-subcountry-perl/current/README?rev=73873&op=diff
==============================================================================
--- branches/upstream/liblocale-subcountry-perl/current/README (original)
+++ branches/upstream/liblocale-subcountry-perl/current/README Sat Apr 30 20:08:00 2011
@@ -4,46 +4,58 @@
 
 SYNOPSIS
 
-   my $UK = new Locale::SubCountry('GB');
-   if ( $UK->has_sub_countries )
-   {
-       print($UK->full_name('DGY'),"\n");           # Dumfries and Galloway
-       print($UK->regional_division('DGY'),"\n");   # SCT (Scotland)
-   }
-
-   my $australia = new Locale::SubCountry('AUSTRALIA');
-   print($australia->country,"\n");                 # AUSTRALIA
-   print($australia->country_code,"\n");            # AU
-
-   if ( $australia->has_sub_countries )
-   {
-       print($australia->code('New South Wales '),"\n");     # NSW
-       print($australia->full_name('S.A.'),"\n");            # South Australia
-       my $upper_case = 1;
-       print($australia->full_name('Qld',$upper_case),"\n"); # QUEENSLAND
-       print($australia->category('NSW'),"\n");              # state
-       print($australia->FIPS10_4_code('ACT'),"\n");         # 01
-       print($australia->ISO3166_2_code('02'),"\n");         # NSW
-
-       my @aus_state_names  = $australia->all_full_names;
-       my @aus_code_names   = $australia->all_codes;
-       my %aus_states_keyed_by_code  = $australia->code_full_name_hash;
-       my %aus_states_keyed_by_name  = $australia->full_name_code_hash;
-
-       foreach my $code ( sort keys %aus_states_keyed_by_code )
-       {
-          printf("%-3s : %s\n",$code,$aus_states_keyed_by_code{$code});
-       }
-   }
-   
-   # Methods for country codes and names
-   
-   my $world = new Locale::SubCountry::World;
-   my @all_countries     = $world->all_full_names;
-   my @all_country_codes = $world->all_codes;
-
-   my %all_countries_keyed_by_name = $world->full_name_code_hash;
-   my %all_country_keyed_by_code   = $world->code_full_name_hash;
+    my $country_code = 'GB';
+    my $UK = new Locale::SubCountry($country_code);
+    if ( not $UK )
+    {
+        die "Invalid code $country_code\n"; 
+    }
+    elsif (  $UK->has_sub_countries )
+    {
+        print($UK->full_name('DGY'),"\n");           # Dumfries and Galloway
+        print($UK->regional_division('DGY'),"\n");   # SCT (Scotland)
+    }
+    
+    my $australia = new Locale::SubCountry('Australia');
+    if ( not $australia )
+    {
+        die "Invalid code: Australia\n"; 
+    }
+    else
+    {
+        print($australia->country,"\n");        # Australia
+        print($australia->country_code,"\n");   # AU
+    
+        if (  $australia->has_sub_countries )
+        {
+            print($australia->code('New South Wales '),"\n");     # NSW
+            print($australia->full_name('S.A.'),"\n");            # South Australia
+            my $upper_case = 1;
+            print($australia->full_name('Qld',$upper_case),"\n"); # QUEENSLAND
+            print($australia->category('NSW'),"\n");              # state
+            print($australia->FIPS10_4_code('ACT'),"\n");         # 01
+            print($australia->ISO3166_2_code('02'),"\n");         # NSW
+      
+            my @aus_state_names  = $australia->all_full_names;
+            my @aus_code_names   = $australia->all_codes;
+            my %aus_states_keyed_by_code  = $australia->code_full_name_hash;
+            my %aus_states_keyed_by_name  = $australia->full_name_code_hash;
+      
+            foreach my $code ( sort keys %aus_states_keyed_by_code )
+            {
+               printf("%-3s : %s\n",$code,$aus_states_keyed_by_code{$code});
+            }   
+        }
+    }
+    
+    # Methods for country codes and names
+    
+    my $world = new Locale::SubCountry::World;
+    my @all_countries     = $world->all_full_names;
+    my @all_country_codes = $world->all_codes;
+    
+    my %all_countries_keyed_by_name = $world->full_name_code_hash;
+    my %all_country_keyed_by_code   = $world->code_full_name_hash;
 
 
 
@@ -94,7 +106,7 @@
 
 COPYRIGHT AND LICENCE
 
-Copyright (C) 2008 by Kim Ryan. All rights reserved.
+Copyright (C) 2011 by Kim Ryan. All rights reserved.
 
 This library is free software; you can redistribute it and/or modify
 it under the same terms as Perl itself.

Modified: branches/upstream/liblocale-subcountry-perl/current/lib/Locale/SubCountry.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/liblocale-subcountry-perl/current/lib/Locale/SubCountry.pm?rev=73873&op=diff
==============================================================================
--- branches/upstream/liblocale-subcountry-perl/current/lib/Locale/SubCountry.pm (original)
+++ branches/upstream/liblocale-subcountry-perl/current/lib/Locale/SubCountry.pm Sat Apr 30 20:08:00 2011
@@ -4,51 +4,58 @@
 
 =head1 SYNOPSIS
 
-   my $country_code = 'GB';
-   my $UK = new Locale::SubCountry($country_code);
-   if ( not $UK )
-   {
-       die "Invalid code $country_code\n"; 
-   }
-   elsif (  $UK->has_sub_countries )
-   {
-       print($UK->full_name('DGY'),"\n");           # Dumfries and Galloway
-       print($UK->regional_division('DGY'),"\n");   # CT (Scotland)
-   }
-
-   my $australia = new Locale::SubCountry('AUstralia');
-   print($australia->country,"\n");                 # Australia
-   print($australia->country_code,"\n");            # AU
-
-   if ( $australia->has_sub_countries )
-   {
-       print($australia->code('New South Wales '),"\n");     # NSW
-       print($australia->full_name('S.A.'),"\n");            # South Australia
-       my $upper_case = 1;
-       print($australia->full_name('Qld',$upper_case),"\n"); # QUEENSLAND
-       print($australia->category('NSW'),"\n");              # state
-       print($australia->FIPS10_4_code('ACT'),"\n");         # 01
-       print($australia->ISO3166_2_code('02'),"\n");         # NSW
-
-       my @aus_state_names  = $australia->all_full_names;
-       my @aus_code_names   = $australia->all_codes;
-       my %aus_states_keyed_by_code  = $australia->code_full_name_hash;
-       my %aus_states_keyed_by_name  = $australia->full_name_code_hash;
-
-       foreach my $code ( sort keys %aus_states_keyed_by_code )
-       {
-          printf("%-3s : %s\n",$code,$aus_states_keyed_by_code{$code});
-       }
-   }
-   
-   # Methods for country codes and names
-   
-   my $world = new Locale::SubCountry::World;
-   my @all_countries     = $world->all_full_names;
-   my @all_country_codes = $world->all_codes;
-
-   my %all_countries_keyed_by_name = $world->full_name_code_hash;
-   my %all_country_keyed_by_code   = $world->code_full_name_hash;
+    my $country_code = 'GB';
+    my $UK = new Locale::SubCountry($country_code);
+    if ( not $UK )
+    {
+        die "Invalid code $country_code\n"; 
+    }
+    elsif (  $UK->has_sub_countries )
+    {
+        print($UK->full_name('DGY'),"\n");           # Dumfries and Galloway
+        print($UK->regional_division('DGY'),"\n");   # SCT (Scotland)
+    }
+    
+    my $australia = new Locale::SubCountry('Australia');
+    if ( not $australia )
+    {
+        die "Invalid code: Australia\n"; 
+    }
+    else
+    {
+        print($australia->country,"\n");        # Australia
+        print($australia->country_code,"\n");   # AU
+    
+        if (  $australia->has_sub_countries )
+        {
+            print($australia->code('New South Wales '),"\n");     # NSW
+            print($australia->full_name('S.A.'),"\n");            # South Australia
+            my $upper_case = 1;
+            print($australia->full_name('Qld',$upper_case),"\n"); # QUEENSLAND
+            print($australia->category('NSW'),"\n");              # state
+            print($australia->FIPS10_4_code('ACT'),"\n");         # 01
+            print($australia->ISO3166_2_code('02'),"\n");         # NSW
+      
+            my @aus_state_names  = $australia->all_full_names;
+            my @aus_code_names   = $australia->all_codes;
+            my %aus_states_keyed_by_code  = $australia->code_full_name_hash;
+            my %aus_states_keyed_by_name  = $australia->full_name_code_hash;
+      
+            foreach my $code ( sort keys %aus_states_keyed_by_code )
+            {
+               printf("%-3s : %s\n",$code,$aus_states_keyed_by_code{$code});
+            }   
+        }
+    }
+    
+    # Methods for country codes and names
+    
+    my $world = new Locale::SubCountry::World;
+    my @all_countries     = $world->all_full_names;
+    my @all_country_codes = $world->all_codes;
+    
+    my %all_countries_keyed_by_name = $world->full_name_code_hash;
+    my %all_country_keyed_by_code   = $world->code_full_name_hash;
 
 
 =head1 DESCRIPTION
@@ -374,7 +381,7 @@
 
 package Locale::SubCountry;
 
-our $VERSION = '1.46';
+our $VERSION = '1.47';
 
 
 #-------------------------------------------------------------------------------
@@ -522,6 +529,7 @@
 
 
     my ($country,$country_code);
+    
 
     # Country may be supplied either as a two letter code, or the full name
     if ( length($country_or_code) == 2 )
@@ -531,8 +539,8 @@
         {
             $country_code = $country_or_code;
             # set country to it's full name
-            $country = $Locale::SubCountry::country_lookup{_code_keyed}{country_code};
-        }
+            $country = $Locale::SubCountry::country_lookup{_code_keyed}{$country_code};
+         }
         else
         {
           warn "Invalid country code: $country_or_code chosen";

Modified: branches/upstream/liblocale-subcountry-perl/current/lib/Locale/SubCountry/Data.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/liblocale-subcountry-perl/current/lib/Locale/SubCountry/Data.pm?rev=73873&op=diff
==============================================================================
--- branches/upstream/liblocale-subcountry-perl/current/lib/Locale/SubCountry/Data.pm (original)
+++ branches/upstream/liblocale-subcountry-perl/current/lib/Locale/SubCountry/Data.pm Sat Apr 30 20:08:00 2011
@@ -32,7 +32,7 @@
 use warnings;
 package Locale::SubCountry::Data;
 
-our $VERSION = '1.46';
+our $VERSION = '1.47';
 
 $Locale::SubCountry::Data::xml_data =
 q{

Modified: branches/upstream/liblocale-subcountry-perl/current/t/main.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/liblocale-subcountry-perl/current/t/main.t?rev=73873&op=diff
==============================================================================
--- branches/upstream/liblocale-subcountry-perl/current/t/main.t (original)
+++ branches/upstream/liblocale-subcountry-perl/current/t/main.t Sat Apr 30 20:08:00 2011
@@ -5,57 +5,62 @@
 #------------------------------------------------------------------------------
 
 use strict;
-use locale;
+use warnings;
+use Test::Simple tests => 18;
 use Locale::SubCountry;
 
-# We start with some black magic to print on failure.
+my $australia = new Locale::SubCountry('Australia');
 
-BEGIN { print "1..17\n"; }
+ok($australia->code('New South Wales ') eq 'NSW', "Convert sub country full name to code");
 
-my $australia = new Locale::SubCountry('Australia');
-print $australia->code('New South Wales ') eq 'NSW' ? "ok 1\n" : "not ok 1\n";
-print $australia->full_name('S.A.') eq 'South Australia' ? "ok 2\n" : "not ok 2\n";
+ok($australia->full_name('S.A.') eq 'South Australia', "Convert sub country code to full name, accounted for full stops");
 
 my $upper_case = 1;
-print $australia->full_name('Qld',$upper_case) eq 'QUEENSLAND'  ? "ok 3\n" : "not ok 3\n";
+ok($australia->full_name('Qld',$upper_case) eq 'QUEENSLAND', "Covert sub country code lower case to full name");
 
-print $australia->country_code eq 'AU' ? "ok 4\n" : "not ok 4\n";
+ok($australia->country_code eq 'AU', "Correct country code for country object");
 
-print $australia->category('NSW') eq 'state' ? "ok 5\n" : "not ok 5\n";
+ok($australia->category('NSW') eq 'state', "Correct category for a sub country code");
 
-print $australia->ISO3166_2_code('01') eq 'ACT' ? "ok 6\n" : "not ok 6\n";
+ok($australia->ISO3166_2_code('01') eq 'ACT', "Convert FIPS code to ISO3166 2 letter code");
 
-print $australia->FIPS10_4_code('ACT') eq '01' ? "ok 7\n" : "not ok 7\n";
+ok($australia->FIPS10_4_code('ACT') eq '01', "Convert ISO3166 2 letter code to FIPS code ");
 
 my %states =  $australia->full_name_code_hash;
-print $states{'Tasmania'} eq 'TAS' ? "ok 8\n" : "not ok 8\n";
+ok($states{'Tasmania'} eq 'TAS', "Contents of full_name_code_hash");
 
 %states =  $australia->code_full_name_hash;
-print $states{'SA'} eq 'South Australia' ? "ok 9\n" : "not ok 9\n";
+ok($states{'SA'} eq 'South Australia' , "Contents of code_full_name_hash");
 
 my @states = $australia->all_codes;
-print @states == 8 ? "ok 10\n" : "not ok 10\n";
+ok(@states == 8, "Total number of sub countries in a country");
 
 my @all_names = $australia->all_full_names;
-print $all_names[1] eq 'New South Wales' ? "ok 11\n" : "not ok 11\n";
+ok($all_names[1] eq 'New South Wales' , "Order of  all_full_names array");
 
+ok($australia->code('Old South Wales ') eq 'unknown', "Unknown sub country full name");
+
+ok($australia->full_name('XYZ') eq 'unknown', "Unknown sub country code");
+
+# Tests for World object
 my $world = new Locale::SubCountry::World;
 
 my %countries =  $world->full_name_code_hash;
-print $countries{'New Zealand'} eq 'NZ' ? "ok 12\n" : "not ok 12\n";
+ok($countries{'New Zealand'} eq 'NZ', "Contents of full_name_code_hash for world object");
 
 %countries =  $world->code_full_name_hash;
-print $countries{'GB'} eq 'United Kingdom' ? "ok 13\n" : "not ok 13\n";
+ok($countries{'GB'} eq 'United Kingdom', "Contents of code_full_name_hash for world object");
 
 my @all_country_codes = $world->all_codes;
-print @all_country_codes ? "ok 14\n" : "not ok 14\n";
+ok(@all_country_codes, "all_codes method returns data for world object");
 
 my @all_country_names = $world->all_full_names;
-print @all_country_names ? "ok 15\n" : "not ok 15\n";
+ok(@all_country_names, "all_full_names method returns data for world object");
 
-print $australia->code('Old South Wales ') eq 'unknown' ? "ok 16\n" : "not ok 16\n";
-
-print $australia->full_name('XYZ') eq 'unknown' ? "ok 17\n" : "not ok 17\n";
+my $UK = new Locale::SubCountry('GB');
+ok($UK->regional_division('DGY') eq 'SCT', "Initialise new method with a 2 letter country code");
 
 
 
+
+




More information about the Pkg-perl-cvs-commits mailing list