7 use Test::Leaner 'no_plan';
9 use Scalar::Vec::Util qw<vshift SVU_SIZE>;
11 for ([ 1, 'offset', -1 ], [ 2, 'length', '-1' ]) {
13 $args[$_->[0]] = $_->[2];
14 eval { &vshift(@args) }; my $line = __LINE__;
15 like $@, qr/^Invalid\s+negative\s+$_->[1]\s+at\s+\Q$0\E\s+line\s+$line/;
23 *myfill = *Scalar::Vec::Util::vfill_pp;
24 *myeq = *Scalar::Vec::Util::veq_pp;
26 sub rst { myfill($_[0], 0, $n, 0); $_[0] = '' }
29 (undef, my $a, my $b, my $x) = @_;
33 myfill($_[0], 0, $a, $x);
34 myfill($_[0], $a, $b, 1 - $x);
39 (undef, my $s, my $l, my $b, my $left, my $insert) = @_;
40 myfill($_[0], 0, $s, 0);
43 myfill($_[0], $s, $b, defined $insert ? $insert : 1);
44 myfill($_[0], $s + $b, $l - $b, 1);
46 myfill($_[0], $s, $l - $b, 1);
47 myfill($_[0], $s + $l - $b, $b, defined $insert ? $insert : 1);
50 myfill($_[0], $s, $l, defined $insert ? $insert : 1);
54 my ($v, $v0, $c) = ('', '') x 2;
57 my ($left, $insert) = @_;
58 my @s = ($p - $q) .. ($p + $q);
60 for my $l (0 .. $n - 1) {
66 push @b, $l2 if $l2 != $l;
71 expect $c, $s, $l, $b, $left, $insert;
72 $b = -$b unless $left;
73 vshift $v, $s, $l => $b, $insert;
74 my $i = defined $insert ? $insert : 'undef';
75 ok(myeq($v, 0, $c, 0, $n), "vshift $s, $l, $b, $i");
76 is(length $v, length $c, "vshift $s, $l, $b, $i length");