X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F32-vcopy-move.t;h=f95fbd43a2417db1b2ee44121c3cdd0ec8c0980b;hb=2bade59206c8f2bd2ed64e1faa8b10cc9109b734;hp=a77183985c7d98998f1a28b79c39dba02a0918b8;hpb=3fdc4bd1cd11d103feda665580f1753297e0a470;p=perl%2Fmodules%2FScalar-Vec-Util.git diff --git a/t/32-vcopy-move.t b/t/32-vcopy-move.t index a771839..f95fbd4 100644 --- a/t/32-vcopy-move.t +++ b/t/32-vcopy-move.t @@ -6,35 +6,39 @@ use warnings; use lib 't/lib'; use Test::Leaner 'no_plan'; -use Scalar::Vec::Util qw/vcopy SVU_SIZE/; +use Scalar::Vec::Util qw; + +BEGIN { + *myfill = *Scalar::Vec::Util::vfill_pp; + *myeq = *Scalar::Vec::Util::veq_pp; +} my $p = SVU_SIZE; -$p = 8 if $p < 8; +$p = 8 if $p < 8; my $n = 3 * $p; my $q = 1; -*myfill = *Scalar::Vec::Util::vfill_pp; -*myeq = *Scalar::Vec::Util::veq_pp; - -sub rst { myfill($_[0], 0, $n, 0); $_[0] = '' } +sub rst { + myfill $_[0], 0, $n, 0; + $_[0] = ''; +} sub pat { - (undef, my $a, my $b, my $x) = @_; - unless ($b) { - rst $_[0]; - } else { + my (undef, $a, $b, $x) = @_; + if ($b) { $_[0] = ''; - myfill($_[0], 0, $a, $x); - myfill($_[0], $a, $b, 1 - $x); - myfill($_[0], $a + $b, $n - ($a + $b), $x) if $a + $b < $n; + myfill $_[0], 0, $a, $x; + myfill $_[0], $a, $b, 1 - $x; + myfill $_[0], $a + $b, $n - ($a + $b), $x if $a + $b < $n; + } else { + rst $_[0]; } } sub prnt { - (undef, my $n, my $desc) = @_; - my $i = 0; - my $s; - $s .= vec($_[0], $i++, 1) while $i < $n; + my (undef, $n, $desc) = @_; + my $s = ''; + $s .= vec($_[0], $_, 1) for 0 .. $n - 1; diag "$desc: $s"; } @@ -48,20 +52,21 @@ for my $s1 (@s) { for my $y (0 .. $q) { last if $s1 + $l + $x > $n or $s1 + $x + $y > $l or $s2 + $l + $x > $n or $s2 + $x + $y > $l; + my $desc = "vcopy [ $x, $y ], $s1, $s2, $l (move)"; pat $v, $s1 + $x, $l - $x - $y, 0; my $v0 = $v; $c = $v; - myfill($c, $s2, $x, 0) if $x; - myfill($c, $s2 + $x, $l - $x - $y, 1); - myfill($c, $s2 + $l - $y, $y, 0) if $y; + myfill $c, $s2, $x, 0 if $x; + myfill $c, $s2 + $x, $l - $x - $y, 1; + myfill $c, $s2 + $l - $y, $y, 0 if $y; vcopy $v => $s1, $v => $s2, $l; - ok(myeq($v, 0, $c, 0, $n), "vcopy [ $x, $y ], $s1, $s2, $l (move)") or do { + is length $v, length $c, "$desc: length"; + ok myeq($v, 0, $c, 0, $n), "$desc: bits" or do { diag "n = $n, s1 = $s1, s2 = $s2, l = $l, x = $x, y = $y"; prnt $v0, $n, 'original'; prnt $v, $n, 'got '; prnt $c, $n, 'expected'; - }; - is(length $v, length $c, "length is ok"); + } } } }