From: Vincent Pit Date: Mon, 24 Sep 2012 22:59:45 +0000 (+0200) Subject: Cover bv_zero() X-Git-Tag: v0.07~2 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=67ef1b78ed684058b943a47d8c2c008718165a2e;p=perl%2Fmodules%2FScalar-Vec-Util.git Cover bv_zero() --- diff --git a/t/11-veq.t b/t/11-veq.t index dab1e05..d6483bb 100644 --- a/t/11-veq.t +++ b/t/11-veq.t @@ -34,25 +34,44 @@ sub rst { } sub pat { - my (undef, $a, $b, $x) = @_; + my (undef, $a, $b, $x, $y) = @_; myfill $_[0], 0, $a, $x; myfill $_[0], $a, $b, 1 - $x; - myfill $_[0], $a + $b, $n - ($a + $b), $x; + myfill $_[0], $a + $b, $n - ($a + $b), $x if $y; } -my ($v1, $v2) = ('') x 2; +my $z = ''; my @s = ($p - $q) .. ($p + $q); for my $s1 (@s) { for my $s2 (@s) { - for my $l (0 .. $n - 1) { + for my $l (0 .. $n) { next if $s1 + $l > $n or $s2 + $l > $n; - pat $v1, $s1, $l, 0; - pat $v2, $s2, $l, 0; - ok veq($v1 => $s1, $v2 => $s2, $l), "veq $s1, $s2, $l"; + my $v1 = ''; + my $v2 = ''; + pat $v1, $s1, $l, 0, 0; + pat $v2, $s2, $l, 0, 1; if ($l > 0) { - ok !veq($v1 => $s1 - 1, $v2 => $s2, $l), 'not veq ' . ($s1-1) . ", $s2, $l"; - ok !veq($v1 => $s1 + 1, $v2 => $s2, $l), 'not veq ' . ($s1+1) . ", $s2, $l"; + my $desc = "not veq 0, 0, $n"; + ok !veq($v1 => 0, $z => 0, $n), "$desc [1<=>0,$l]"; + ok !veq($z => 0, $v1 => 0, $n), "$desc [0<=>1,$l]"; + } + for my $r ($l, $l + $n + 1) { + my $desc = "veq $s1, $s2, $r"; + ok veq($v1 => $s1, $v2 => $s2, $r), "$desc [1<=>2,$l]"; + ok veq($v2 => $s2, $v1 => $s1, $r), "$desc [2<=>1,$l]"; + if ($l > 0) { # Implies $r > 0 + if ($s1 > 0) { + my $desc = 'not veq ' . ($s1 - 1). ", $s2, $r"; + ok !veq($v1 => $s1-1, $v2 => $s2, $r), "$desc [1-1<=>2,$l]"; + ok !veq($v2 => $s2, $v1 => $s1-1, $r), "$desc [2<=>1-1,$l]"; + } + { + my $desc = 'not veq ' . ($s1 + 1). ", $s2, $r"; + ok !veq($v1 => $s1+1, $v2 => $s2, $r), "$desc [1+1<=>2,$l]"; + ok !veq($v2 => $s2, $v1 => $s1+1, $r), "$desc [2<=>1+1,$l]"; + } + } } } }