X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2FScalar-Vec-Util.git;a=blobdiff_plain;f=t%2F21-vfill.t;h=3b6a27a837f5d5e14ad2eb6235111e1eded9042b;hp=84031743e370403f2a8b1e464128a1b17c7f8290;hb=2bade59206c8f2bd2ed64e1faa8b10cc9109b734;hpb=eb5fc894300e2e78d7beeb03f47f9d8e488518d5 diff --git a/t/21-vfill.t b/t/21-vfill.t index 8403174..3b6a27a 100644 --- a/t/21-vfill.t +++ b/t/21-vfill.t @@ -7,29 +7,38 @@ use Test::More 'no_plan'; use Scalar::Vec::Util qw; +BEGIN { + *myfill = *Scalar::Vec::Util::vfill_pp; + *myeq = *Scalar::Vec::Util::veq_pp; +} + for ([ 1, 'offset', -1 ], [ 2, 'length', '-1' ]) { my @args = (~0) x 4; $args[$_->[0]] = $_->[2]; - eval { &vfill(@args) }; my $line = __LINE__; - like $@, qr/^Invalid\s+negative\s+$_->[1]\s+at\s+\Q$0\E\s+line\s+$line/; + local $@; + eval { &vfill(@args) }; + my $err = $@; + my $line = __LINE__-2; + like $err, qr/^Invalid\s+negative\s+$_->[1]\s+at\s+\Q$0\E\s+line\s+$line/, + "vfill(@args) failed"; } 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) = @_; + my (undef, $a, $b, $x) = @_; $_[0] = ''; if ($b) { - myfill($_[0], 0, $a, $x); - myfill($_[0], $a, $b, 1 - $x); + myfill $_[0], 0, $a, $x; + myfill $_[0], $a, $b, 1 - $x; } } @@ -39,10 +48,11 @@ my @s = ($p - $q) .. ($p + $q); for my $s (@s) { for my $l (0 .. $n - 1) { next if $s + $l > $n; + my $desc = "vfill $s, $l"; pat $c, $s, $l, 0; rst $v; vfill $v, $s, $l, 1; - ok(myeq($v, 0, $c, 0, $n), "vfill $s, $l"); - is(length $v, length $c, "length is ok"); + is length $v, length $c, "$desc: length"; + ok myeq($v, 0, $c, 0, $n), "$desc: bits"; } }