diff options
author | Kenichi Ishigaki <ishigaki@cpan.org> | 2013-11-17 04:29:21 +0900 |
---|---|---|
committer | Kenichi Ishigaki <ishigaki@cpan.org> | 2013-11-17 04:29:21 +0900 |
commit | 19756eb4c2f539cdefc4f3470afbbb0f21b480f0 (patch) | |
tree | e217350ef3582bfa7a3216ebb21c501253c3023d | |
parent | c1f0a83762931a8b73ce0741b09b3576e5fb6107 (diff) |
deref a version set as *VERSION = \...
-rw-r--r-- | lib/Parse/PMFile.pm | 5 | ||||
-rw-r--r-- | xt/acme_lvalue.t | 46 |
2 files changed, 49 insertions, 2 deletions
diff --git a/lib/Parse/PMFile.pm b/lib/Parse/PMFile.pm index e8371a9..274847f 100644 --- a/lib/Parse/PMFile.pm +++ b/lib/Parse/PMFile.pm @@ -178,9 +178,10 @@ sub _parse_version { my $err = $@; # warn ">>>>>>>err[$err]<<<<<<<<"; if (ref $err) { - if ($err->{line} =~ /[\$*]([\w\:\']*)\bVERSION\b.*?\=(.*)/) { + if ($err->{line} =~ /([\$*])([\w\:\']*)\bVERSION\b.*?\=(.*)/) { local($^W) = 0; - $v = $comp->reval($2); + $v = $comp->reval($3); + $v = $$v if $1 eq '*'; } if ($@ or !$v) { $self->_verbose(1, sprintf("reval failed: err[%s] for eval[%s]", diff --git a/xt/acme_lvalue.t b/xt/acme_lvalue.t new file mode 100644 index 0000000..f46b206 --- /dev/null +++ b/xt/acme_lvalue.t @@ -0,0 +1,46 @@ +use strict; +use warnings; +use Test::More; +use ExtUtils::MakeMaker; + +plan skip_all => "requires WorePAN" unless eval "use WorePAN 0.03; 1"; +my @tests = ( + ['M/MA/MAUKE/Acme-Lvalue-0.03.tar.gz', 'lib/Acme/Lvalue.pm', 'Acme::Lvalue', '0.03'], +); + +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, "parsed successfully in time"; + note $@ if $@; + note explain $info; + note explain $errs if $errs; + + note "EUMM: ". MM->parse_version($file); + }); +} + +done_testing; |