Skip to content

Commit

Permalink
Added t/strict.t
Browse files Browse the repository at this point in the history
  • Loading branch information
Nigel Horne committed Mar 2, 2021
1 parent 69a5a3e commit af576eb
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 7 deletions.
1 change: 1 addition & 0 deletions MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ t/pod.t
t/port.t
t/snippets.t
t/spelling.t
t/strict.t
t/translate.t
t/unused.t
t/vars.t
11 changes: 6 additions & 5 deletions lib/Locale/Places.pm
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,12 @@ sub translate {
return $line->{'data'};
}
} elsif(scalar(@places) > 1) {
foreach my $p(@places) {
if(my $line = $self->{'gb'}->fetchrow_hashref({ type => $to, code2 => $p->{'code2'} })) {
return $line->{'data'};
}
}
Carp::croak(__PACKAGE__, "Database has more than one preferred entry for $place in language $to");
# foreach my $p(@places) {
# if(my $line = $self->{'gb'}->fetchrow_hashref({ type => $to, code2 => $p->{'code2'} })) {
# return $line->{'data'};
# }
# }
}
return; # undef
}
Expand Down
4 changes: 3 additions & 1 deletion t/carp.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use strict;
use warnings;
use Test::Carp;
use Test::Most tests => 9;
use Test::Most tests => 10;

BEGIN {
use_ok('Locale::Places');
Expand All @@ -28,4 +28,6 @@ CARP: {

does_carp_that_matches(sub { $places->translate('London') }, qr/can't work out which language to translate to/);
does_carp_that_matches(sub { $places->translate({ place => 'London', to => 'y' }) }, qr/can't work out which language to translate from/);

does_carp_that_matches(sub { $places->translate(place => 'Dover', from => undef) }, qr/usage/);
}
2 changes: 1 addition & 1 deletion t/gb.t
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!perl -wT

# Check the GBN database is sensible
# Check the GB database is sensible

use strict;
use warnings;
Expand Down
20 changes: 20 additions & 0 deletions t/strict.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!perl -w

use strict;
use warnings;

use Test::Most;

if($ENV{AUTHOR_TESTING}) {
eval 'use Test::Strict';
if($@) {
plan(skip_all => 'Test::Strict required for testing use strict');
} else {
all_perl_files_ok();
warnings_ok('lib/Locale/Places.pm');
warnings_ok('lib/Locale/Places/DB.pm');
warnings_ok('lib/Locale/Places/DB/GB.pm');
}
} else {
plan(skip_all => 'Author tests not required for installation');
}

0 comments on commit af576eb

Please sign in to comment.