7 use Test::Leaner 'no_plan';
9 use Scalar::Vec::Util qw<vrot vcopy SVU_SIZE>;
11 for ([ 1, 'offset', -1 ], [ 2, 'length', '-1' ]) {
13 $args[$_->[0]] = $_->[2];
14 eval { &vrot(@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 $c, my $x) = @_;
31 myfill($_[0], 0, $a, $x);
32 myfill($_[0], $a, $b, 1 - $x);
33 myfill($_[0], $a + $b, $c, $x);
34 myfill($_[0], $a + $b + $c, $n - ($a + $b + $c), 1 - $x);
38 (undef, my $s, my $l, my $b, my $left) = @_;
40 myfill($_[0], 0, $s, 0);
41 myfill($_[0], $s, $n - $s, 1);
48 myfill($_[0], 0, $s, 0);
51 myfill($_[0], $s, $b, 0);
52 myfill($_[0], $s + $b, $lx, 1);
53 myfill($_[0], $s + $b + $lx, $l - $lx - $b, 0);
55 myfill($_[0], $s, $b - $ly, 1);
56 myfill($_[0], $s + $b - $ly, $ly, 0);
57 myfill($_[0], $s + $b, $l - $b, 1);
61 myfill($_[0], $s, $lx - $b, 1);
62 myfill($_[0], $s + $lx - $b, $l - $lx, 0);
63 myfill($_[0], $s + $l - $b, $b, 1);
65 myfill($_[0], $s, $ly - ($b - $lx), 0);
66 myfill($_[0], $s + $l - $b, $lx, 1);
67 myfill($_[0], $s + $l + $lx - $b, $b - $lx, 0);
70 myfill($_[0], $s + $l, $n - $s - $l, 1);
74 (undef, my $n, my $desc) = @_;
77 $s .= vec($_[0], $i++, 1) while $i < $n;
81 my ($v, $v0, $c) = ('', '') x 2;
85 my @s = ($p - $q) .. ($p + $q);
87 for my $l (0 .. $n - 1) {
91 pat $v0, $s, $l2, $l - $l2, 0;
92 my @b = (0, 3, 5, 7, 11, 13, 17, $l2, $l2 + 1, $l + 1);
93 @b = do { my %seen; ++$seen{$_} for @b; sort keys %seen };
96 expected $c, $s, $l, $b, $left;
97 $b = -$b unless $left;
99 ok(myeq($v, 0, $c, 0, $n), "vrot $s, $l, $b") or do {
100 diag "n = $n, s = $s, l = $l, l2 = $l2";
101 prnt $v0, $n, 'original';
103 prnt $c, $n, 'expected';
105 is(length $v, length $c, "vrot $s, $l, $b length");