| 1 |
#!/usr/bin/perl |
| 2 |
|
| 3 |
# If you run into an ISBN that you think is valid but this module |
| 4 |
# says is invalid, put it here. |
| 5 |
# |
| 6 |
# Grab the latest RangeMessage.xml file and see if the distributed |
| 7 |
# data is just out of date. |
| 8 |
my @isbns_from_issues = qw( |
| 9 |
9782021183061 |
| 10 |
); |
| 11 |
|
| 12 |
|
| 13 |
use Test::More; |
| 14 |
|
| 15 |
use Data::Dumper; |
| 16 |
use File::Spec::Functions qw(catfile); |
| 17 |
|
| 18 |
SKIP: { |
| 19 |
my $tests = @isbns_from_issues + 3; |
| 20 |
skip "Need Business::ISBN 3.006 to run this test", $tests unless eval { |
| 21 |
require Business::ISBN; |
| 22 |
# 3.005 fixed a major problem with 979 numbers and the data |
| 23 |
# structure changed. |
| 24 |
Business::ISBN->VERSION('3.006'); |
| 25 |
}; |
| 26 |
|
| 27 |
diag( "Business::ISBN is " . Business::ISBN->VERSION ); |
| 28 |
|
| 29 |
my $file = catfile( qw(blib lib Business ISBN RangeMessage.xml) ); |
| 30 |
my $out_of_the_way = $file . '.hidden'; |
| 31 |
|
| •32 |
ok( rename($file => $out_of_the_way), 'Renamed file' ) unless $ENV{AUTOPKGTEST_TMP}; |
| 33 |
|
| 34 |
subtest 'compile' => sub { |
| 35 |
my @modules = qw( Business::ISBN::Data ); |
| 36 |
foreach my $module ( @modules ) { |
| 37 |
BAIL_OUT( "Could not load $module" ) unless eval{ use_ok( $module ) }; |
| 38 |
} |
| 39 |
}; |
| 40 |
|
| 41 |
local %Business::ISBN::country_data = Business::ISBN::Data::_get_data(); |
| 42 |
like( $Business::ISBN::country_data{_source}, qr/\bData\.pm/, 'Data source is the default data structure' ); |
| 43 |
|
| 44 |
subtest 'check_isbns' => sub { |
| 45 |
foreach my $isbn ( @isbns_from_issues ) { |
| 46 |
my $i = Business::ISBN->new( $isbn ); |
| 47 |
ok( $i->is_valid, "<$isbn> is valid" ); |
| 48 |
} |
| 49 |
}; |
| 50 |
|
| •51 |
rename $out_of_the_way => $file unless $ENV{AUTOPKGTEST_TMP}; |
| 52 |
} |
| 53 |
|
| 54 |
done_testing(); |