X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F31-atom-cmp.t;h=9422071f4e8481832a156a133f8e47a713962ff3;hb=f1e11349a9e94499b1025601c2f7e4c73e18810e;hp=577047114f5dc17976f143c3e2f62a87f6e74802;hpb=9e50d0a5cd63e13e194009d6fbdedb75e75eaa5e;p=perl%2Fmodules%2FCPANPLUS-Dist-Gentoo.git diff --git a/t/31-atom-cmp.t b/t/31-atom-cmp.t index 5770471..9422071 100644 --- a/t/31-atom-cmp.t +++ b/t/31-atom-cmp.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 4 * ((8 * 7) / 2); +use Test::More tests => 2 * 8 * ((8 * 7) / 2); use CPANPLUS::Dist::Gentoo::Atom; @@ -98,8 +98,12 @@ sub compare_ok { my $desc = join " $cmp ", map "'$_'", $a, $b; - my $c = eval "\$a $cmp \$b"; - my $err = $@; + my ($err, $c); + { + local $@; + $c = eval "\$a $cmp \$b"; + $err = $@; + } if (ref $exp eq 'Regexp') { like $err, $exp, "$desc should fail"; @@ -120,6 +124,27 @@ for my $t (@tests) { } compare_ok($a, '<=>', $b, $exp); + + my $bs = "$b"; + compare_ok($a, '<=>', $bs, $exp); + + my $bv = $b->version; + if (defined $bv) { + compare_ok($a, '<=>', $bv, $exp); + compare_ok($a, '<=>', "$bv", $exp); + } else { + pass("$bs has no version part ($_)") for 1, 2; + } + compare_ok($a, 'cmp', $b, $exp); + + my $bz = $b->qualified_name; + $bz .= "-$bv" if defined $bv; + compare_ok($a, 'cmp', $bz, $exp); + + $bz = "test/zzz"; + $bz .= "-$bv" if defined $bv; + compare_ok($a, 'cmp', $bz, -1); + compare_ok($bz, 'cmp', $b, 1); } }