test detection of nonsensical parameter lists
Lukas Mai [Wed, 10 Aug 2011 03:54:57 +0000 (05:54 +0200)]
t/strict.t [new file with mode: 0644]
t/strict_1.fail [new file with mode: 0644]
t/strict_2.fail [new file with mode: 0644]
t/strict_3.fail [new file with mode: 0644]
t/strict_4.fail [new file with mode: 0644]

diff --git a/t/strict.t b/t/strict.t
new file mode 100644 (file)
index 0000000..4ebc8d8
--- /dev/null
@@ -0,0 +1,23 @@
+use warnings;
+use strict;
+
+use Test::More tests => 8;
+
+use Dir::Self;
+
+for my $fail (
+       map [__DIR__ . "/strict_$_->[0].fail", @$_[1 .. $#$_]],
+       ['1', qr/expect.*\).*after.*"\@y".*"\$z"/],
+       ['2', qr/expect.*\).*after.*"\@x".*"\$y"/],
+       ['3', qr/expect.*\).*after.*"%y".*"\$z"/],
+       ['4', qr/expect.*\).*after.*"\@y".*"\@z"/],
+) {
+       my ($file, $pat) = @$fail;
+       my $done = do $file;
+       my $exc = $@;
+       my $err = $!;
+
+       is $done, undef, "faulty code doesn't load";
+       $exc or die "$file: $err" if $err;
+       like $exc, $pat;
+}
diff --git a/t/strict_1.fail b/t/strict_1.fail
new file mode 100644 (file)
index 0000000..6a9cfcd
--- /dev/null
@@ -0,0 +1,7 @@
+#!perl
+use warnings;
+use strict;
+
+use Function::Parameters;
+
+fun bad_1($x, @y, $z) {}
diff --git a/t/strict_2.fail b/t/strict_2.fail
new file mode 100644 (file)
index 0000000..edbc47b
--- /dev/null
@@ -0,0 +1,7 @@
+#!perl
+use warnings;
+use strict;
+
+use Function::Parameters;
+
+fun bad_2(@x, $y) {}
diff --git a/t/strict_3.fail b/t/strict_3.fail
new file mode 100644 (file)
index 0000000..3560b99
--- /dev/null
@@ -0,0 +1,7 @@
+#!perl
+use warnings;
+use strict;
+
+use Function::Parameters;
+
+fun bad_3($x, %y, $z) {}
diff --git a/t/strict_4.fail b/t/strict_4.fail
new file mode 100644 (file)
index 0000000..203afd5
--- /dev/null
@@ -0,0 +1,7 @@
+#!perl
+use warnings;
+use strict;
+
+use Function::Parameters;
+
+fun bad_4(@y, @z) {}