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