From: Vincent Pit Date: Sat, 11 Sep 2010 14:32:50 +0000 (+0200) Subject: Extend coverage of spaceship operators for atoms X-Git-Tag: v0.11~19 X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2FCPANPLUS-Dist-Gentoo.git;a=commitdiff_plain;h=224b04a18dc0a67240dc93d03b04f8804bf1bc91 Extend coverage of spaceship operators for atoms --- diff --git a/t/31-atom-cmp.t b/t/31-atom-cmp.t index 82623d7..5801010 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 => 6 * ((8 * 7) / 2); +use Test::More tests => 2 * 5 * ((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,7 +124,17 @@ for my $t (@tests) { } compare_ok($a, '<=>', $b, $exp); - compare_ok($a, '<=>', "$b", $exp); + + my $bs = "$b"; + compare_ok($a, '<=>', $bs, $exp); + + if (my $bv = $b->version) { + 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); } }