From: Vincent Pit Date: Sat, 11 Sep 2010 13:32:47 +0000 (+0200) Subject: Fix handling of the version argument of C::D::G::Atom->new X-Git-Tag: v0.11~22 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=a3d7c9d6304ce5516bdb44d28ec2eba9c57082f3;p=perl%2Fmodules%2FCPANPLUS-Dist-Gentoo.git Fix handling of the version argument of C::D::G::Atom->new --- diff --git a/lib/CPANPLUS/Dist/Gentoo/Atom.pm b/lib/CPANPLUS/Dist/Gentoo/Atom.pm index 33c622c..fcfa685 100644 --- a/lib/CPANPLUS/Dist/Gentoo/Atom.pm +++ b/lib/CPANPLUS/Dist/Gentoo/Atom.pm @@ -68,7 +68,7 @@ sub new { if (defined $version) { unless (Scalar::Util::blessed($version) - and $_->isa('CPANPLUS::Dist::Gentoo::Version')) { + and $version->isa('CPANPLUS::Dist::Gentoo::Version')) { $version = CPANPLUS::Dist::Gentoo::Version->new($version); } } diff --git a/t/30-atom-new.t b/t/30-atom-new.t index a28b290..dec89c2 100644 --- a/t/30-atom-new.t +++ b/t/30-atom-new.t @@ -3,15 +3,16 @@ use strict; use warnings; -use Test::More tests => 23; +use Test::More tests => 25; use CPANPLUS::Dist::Gentoo::Atom; sub A () { 'CPANPLUS::Dist::Gentoo::Atom' } -my $no_info = qr/^Not enough information/; -my $no_category = qr/^Category unspecified/; -my $range_no_ver = qr/^Range atoms require a valid version/; +my $no_info = qr/^Not enough information/; +my $no_category = qr/^Category unspecified/; +my $range_no_ver = qr/^Range atoms require a valid version/; +my $cant_parse_ver = qr/^Couldn't parse version string/; sub inv { qr/^Invalid \Q$_[0]\E/ } @@ -19,6 +20,9 @@ my $a0 = { category => 'test', name => 'a' }; my $a1 = { category => 'test', name => 'a', version => '1.0' }; my $a2 = { category => 'test+', name => 'a+b', version => '1.2.3' }; +my $v0 = bless { }, 'CPANPLUS::Dist::Gentoo::Test::FakeVersion'; +my $v1 = CPANPLUS::Dist::Gentoo::Version->new('0.1.2-r3'); + my @tests = ( [ { } => $no_info ], [ { category => 'test' } => $no_info ], @@ -32,9 +36,12 @@ my @tests = ( [ $a0 => $a0 ], [ { %$a0, range => '' } => { %$a0, range => '' } ], [ { %$a0, range => '<=' } => $range_no_ver ], - [ $a1 => { %$a1, range => '>=' } ], - [ { %$a1, range => '<>' } => inv('range'), ], - [ { %$a1, range => '<=' } => { %$a1, range => '<=' } ], + + [ $a1 => { %$a1, range => '>=' } ], + [ { %$a1, version => $v0 } => $cant_parse_ver ], + [ { %$a1, version => $v1 } => { %$a1, range => '>=', version => '0.1.2-r3' } ], + [ { %$a1, range => '<>' } => inv('range'), ], + [ { %$a1, range => '<=' } => { %$a1, range => '<=' } ], [ { atom => 'test/a' } => $a0 ], [ { atom => 'test/a-1.0' } => { %$a1, range => '>=' } ],