7 use Test::Leaner 'no_plan';
9 use Scalar::Vec::Util qw<vshift SVU_SIZE>;
12 *myfill = *Scalar::Vec::Util::vfill_pp;
13 *myeq = *Scalar::Vec::Util::veq_pp;
16 for ([ 1, 'offset', -1 ], [ 2, 'length', '-1' ]) {
18 $args[$_->[0]] = $_->[2];
20 eval { &vshift(@args) };
22 my $line = __LINE__-2;
23 like $err, qr/^Invalid\s+negative\s+$_->[1]\s+at\s+\Q$0\E\s+line\s+$line/,
24 "vshift(@args) failed";
33 myfill $_[0], 0, $n, 0;
38 my (undef, $a, $b, $x) = @_;
42 myfill $_[0], 0, $a, $x;
43 myfill $_[0], $a, $b, 1 - $x;
48 my (undef, $s, $l, $b, $left, $insert) = @_;
49 myfill $_[0], 0, $s, 0;
52 myfill $_[0], $s, $b, defined $insert ? $insert : 1;
53 myfill $_[0], $s + $b, $l - $b, 1;
55 myfill $_[0], $s, $l - $b, 1;
56 myfill $_[0], $s + $l - $b, $b, defined $insert ? $insert : 1;
59 myfill $_[0], $s, $l, defined $insert ? $insert : 1;
63 my ($v, $v0, $c) = ('', '') x 2;
66 my ($left, $insert) = @_;
67 my @s = ($p - $q) .. ($p + $q);
69 for my $l (0 .. $n - 1) {
75 push @b, $l2 if $l2 != $l;
78 my $desc = "vshift $s, $l, $b, " . (defined $insert ? $insert : 'undef');
81 expect $c, $s, $l, $b, $left, $insert;
82 $b = -$b unless $left;
83 vshift $v, $s, $l => $b, $insert;
84 is length $v, length $c, "$desc: length";
85 ok myeq($v, 0, $c, 0, $n), "$desc: bits";