X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2FScalar-Vec-Util.git;a=blobdiff_plain;f=t%2F20-vfill-pp.t;h=2d9e00e8ce9000df4d9363c19c258e58daf6ffc5;hp=3bb893d4c064e2d2992cf77dbd820f6efc3e8944;hb=2bade59206c8f2bd2ed64e1faa8b10cc9109b734;hpb=eb5fc894300e2e78d7beeb03f47f9d8e488518d5 diff --git a/t/20-vfill-pp.t b/t/20-vfill-pp.t index 3bb893d..2d9e00e 100644 --- a/t/20-vfill-pp.t +++ b/t/20-vfill-pp.t @@ -7,11 +7,19 @@ use Test::More 'no_plan'; use Scalar::Vec::Util; +BEGIN { + *myeq = *Scalar::Vec::Util::veq_pp; +} + for ([ 1, 'offset', -1 ], [ 2, 'length', '-1' ]) { my @args = ('1') x 4; $args[$_->[0]] = $_->[2]; - eval { &Scalar::Vec::Util::vfill_pp(@args) }; my $line = __LINE__; - like $@, qr/^Invalid\s+negative\s+$_->[1]\s+at\s+\Q$0\E\s+line\s+$line/; + local $@; + eval { &Scalar::Vec::Util::vfill_pp(@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_pp(@args) failed"; } my $p = 8; @@ -19,14 +27,15 @@ my $n = 3 * $p; my $q = 1; sub myfill { - (undef, my $s, my $l, my $x) = @_; + my (undef, $s, $l, $x) = @_; $x = 1 if $x; vec($_[0], $_, 1) = $x for $s .. $s + $l - 1; } -*myeq = *Scalar::Vec::Util::veq_pp; - -sub rst { myfill($_[0], 0, $n, 0); $_[0] = '' } +sub rst { + myfill $_[0], 0, $n, 0; + $_[0] = ''; +} my ($v, $c) = ('') x 2; @@ -34,13 +43,14 @@ my @s = ($p - $q) .. ($p + $q); for my $s (@s) { for my $l (0 .. $n - 1) { next if $s + $l > $n; + my $desc = "vfill_pp $s, $l"; rst $c; - myfill($c, 0, $s, 0); - myfill($c, $s, $l, 1); + myfill $c, 0, $s, 0; + myfill $c, $s, $l, 1; rst $v; Scalar::Vec::Util::vfill_pp($v, 0, $s, 0); Scalar::Vec::Util::vfill_pp($v, $s, $l, 1); - ok(myeq($v, 0, $c, 0, $n), "vfill_pp $s, $l"); - is(length $v, length $c, "vfill_pp $s, $l length"); + is length $v, length $c, "$desc: length"; + ok myeq($v, 0, $c, 0, $n), "$desc: bits"; } }