]> git.vpit.fr Git - perl/modules/Scalar-Vec-Util.git/blobdiff - t/21-vfill.t
Improve argument checking
[perl/modules/Scalar-Vec-Util.git] / t / 21-vfill.t
index 33565f954bcb9b89adee5a838ad396a25ef0019c..47026688f04636d7b9b1fed3a48acdd1e8bf7e95 100644 (file)
@@ -7,14 +7,12 @@ use Test::More 'no_plan';
 
 use Scalar::Vec::Util qw/vfill SVU_SIZE/;
 
-eval { vfill undef, 0, 0, 0 };
-like($@, qr/Invalid\s+argument/, 'first argument undef croaks');
-eval { vfill my $x, undef, 0, 0 };
-like($@, qr/Invalid\s+argument/, 'second argument undef croaks');
-eval { vfill my $x, 0, undef, 0 };
-like($@, qr/Invalid\s+argument/, 'third argument undef croaks');
-eval { vfill my $x, 0, 0, undef };
-like($@, qr/Invalid\s+argument/, 'fourth argument undef croaks');
+for ([ 1, 'offset', -1 ], [ 2, 'length', '-1' ]) {
+ my @args  = (~0) x 4;
+ $args[$_->[0]] = $_->[2];
+ eval { &vfill(@args) }; my $line = __LINE__;
+ like $@, qr/^Invalid\s+negative\s+$_->[1]\s+at\s+\Q$0\E\s+line\s+$line/;
+}
 
 my $p = SVU_SIZE;
 $p = 8 if $p < 8;