Permalink
Browse files

Fix Number::Phone::UK constructor bug - was returning 0 instead of un…

…def for invalid numbers
  • Loading branch information...
DrHyde committed Apr 22, 2009
1 parent 68b0304 commit abedb2d1234a2178ba99204e9ba1c7e2a5de2694
Showing with 19 additions and 4 deletions.
  1. +5 −0 CHANGELOG
  2. +1 −1 lib/Number/Phone.pm
  3. +4 −2 lib/Number/Phone/UK.pm
  4. +9 −1 t/01_uk_data.t
View
@@ -1,3 +1,8 @@
+2009-04-22 1.7002 Fix minor bug (...::UK constructor returning 0
+ instead of undef for (some?) invalid numbers,
+ reported by Tomasz Chomiuk;
+ New UK allocations
+
2009-03-04 1.7001 Kill warnings about GE being deprecated;
Add missing dep on Digest::MD5
View
@@ -6,7 +6,7 @@ use Scalar::Util 'blessed';
use Number::Phone::Country qw(noexport uk);
-our $VERSION = 1.7001;
+our $VERSION = 1.7002;
my @is_methods = qw(
is_valid is_allocated is_in_use
View
@@ -7,7 +7,7 @@ use Number::Phone::UK::Data;
use base 'Number::Phone';
-our $VERSION = 1.552;
+our $VERSION = 1.553;
my $cache = {};
@@ -28,7 +28,9 @@ sub new {
my $number = shift;
die("No number given to ".__PACKAGE__."->new()\n") unless($number);
- return bless(\$number, $class) if(is_valid($number));
+ if(is_valid($number)) {
+ return bless(\$number, $class);
+ } else { return undef; }
}
=head1 METHODS
View
@@ -6,7 +6,7 @@ use strict;
use Number::Phone::UK;
-BEGIN { $| = 1; print "1..61\n"; }
+BEGIN { $| = 1; print "1..63\n"; }
my $test = 0;
@@ -172,3 +172,11 @@ print 'ok '.(++$test)." unallocated numbers format OK\n";
$number = Number::Phone->new('+441954202020');
print 'not ' unless($number->format() eq '+44 1954 202020');
print 'ok '.(++$test)." allocated numbers format OK\n";
+
+$number = Number::Phone::UK->new('0844000000');
+print 'not ' if(defined($number));
+print 'ok '.(++$test)." 0844 000 000 is invalid (too short)\n";
+
+$number = Number::Phone->new('+44844000000');
+print 'not ' if(defined($number));
+print 'ok '.(++$test)." +44 844 000 000 is invalid (too short)\n";

0 comments on commit abedb2d

Please sign in to comment.