X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2FScalar-Vec-Util.git;a=blobdiff_plain;f=t%2F30-vcopy-pp.t;h=911b5a1f90d85bc463476dacc12c390131f2af6c;hp=fda3803eb35f2e1f750ef95567c9eadf6126e616;hb=2bade59206c8f2bd2ed64e1faa8b10cc9109b734;hpb=eb5fc894300e2e78d7beeb03f47f9d8e488518d5 diff --git a/t/30-vcopy-pp.t b/t/30-vcopy-pp.t index fda3803..911b5a1 100644 --- a/t/30-vcopy-pp.t +++ b/t/30-vcopy-pp.t @@ -8,28 +8,36 @@ use Test::Leaner 'no_plan'; use Scalar::Vec::Util qw; +BEGIN { + *myfill = *Scalar::Vec::Util::vfill_pp; +} + for ([ 1, 'offset', -1 ], [ 3, 'offset', '-1' ], [ 4, 'length', -1 ]) { my @args = ('1') x 5; $args[$_->[0]] = $_->[2]; - eval { &Scalar::Vec::Util::vcopy_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::vcopy_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/, + "vcopy_pp(@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; +sub rst { + myfill $_[0], 0, $n, 0; +} -sub rst { myfill($_[0], 0, $n, 0) } - sub pat { - (undef, my $a, my $b, my $x) = @_; - myfill($_[0], 0, $a, $x); - myfill($_[0], $a, $b, 1 - $x); - myfill($_[0], $a + $b, $n - ($a + $b) , $x); -} + my (undef, $a, $b, $x) = @_; + myfill $_[0], 0, $a, $x; + myfill $_[0], $a, $b, 1 - $x; + myfill $_[0], $a + $b, $n - ($a + $b), $x; +} my ($f, $t, $c) = ('') x 3; @@ -38,11 +46,12 @@ for my $s1 (@s) { for my $s2 (@s) { for my $l (0 .. $n - 1) { last if $s1 + $l > $n or $s2 + $l > $n; + my $desc = "vcopy_pp $s1, $s2, $l"; pat $f, $s1, $l, 0; rst $t; pat $c, $s2, $l, 0; Scalar::Vec::Util::vcopy_pp($f => $s1, $t => $s2, $l); - is($t, $c, "vcopy_pp $s1, $s2, $l"); + is $t, $c, $desc; } } }