summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenichi Ishigaki <ishigaki@cpan.org>2013-10-12 02:01:04 +0900
committerKenichi Ishigaki <ishigaki@cpan.org>2013-10-12 02:01:04 +0900
commit11501166f275ca172b54ab140921393d2a9f2b28 (patch)
treedfd721e9e2ecfb0019626b49c557c77fe5bdd74c
parentfc60eefc231f4c1315e6de2fc8d7c8df8702361f (diff)
added an extra test for an invalid version (normalization failure)
-rw-r--r--xt/games_cards_poker.t44
1 files changed, 44 insertions, 0 deletions
diff --git a/xt/games_cards_poker.t b/xt/games_cards_poker.t
new file mode 100644
index 0000000..06f18f9
--- /dev/null
+++ b/xt/games_cards_poker.t
@@ -0,0 +1,44 @@
+use strict;
+use warnings;
+use Test::More;
+
+plan skip_all => "requires WorePAN" unless eval "use WorePAN 0.03; 1";
+my @tests = (
+ ['P/PI/PIP/Games-Cards-Poker-1.2.4CCJ12M.tgz', 'Poker.pm', 'Games::Cards::Poker', 'undef'],
+);
+
+for my $test (@tests) {
+ my ($path, $pmfile, $package, $version) = @$test;
+ note "downloading $path...";
+
+ my $worepan = WorePAN->new(
+ no_network => 0,
+ use_backpan => 1,
+ cleanup => 1,
+ no_indices => 1,
+ files => [$path],
+ );
+
+ note "parsing $path...";
+
+ $worepan->walk(callback => sub {
+ my $dir = shift;
+ my $file = $dir->file($pmfile);
+ my $parser = Parse::PMFile->new;
+
+ my ($info, $errs);
+ eval {
+ local $SIG{ALRM} = sub { die "timeout\n" };
+ alarm 30;
+ ($info, $errs) = $parser->parse($file);
+ alarm 0;
+ };
+ ok !$@ && ref $info eq ref {} && $info->{$package}{version} eq $version, "returned no version";
+ ok !$@ && ref $errs eq ref {} && $errs->{$package}{normalize}, "returned invalid version";
+ note $@ if $@;
+ note explain $info;
+ note explain $errs;
+ });
+}
+
+done_testing;