From: Lukas Mai Date: Wed, 10 Aug 2011 03:54:57 +0000 (+0200) Subject: test detection of nonsensical parameter lists X-Git-Tag: v0.05_01~7 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=87b6b3ed50ab4a539cb0dc0a420db4faa7bd82a4;p=p5sagit%2FFunction-Parameters.git test detection of nonsensical parameter lists --- diff --git a/t/strict.t b/t/strict.t new file mode 100644 index 0000000..4ebc8d8 --- /dev/null +++ b/t/strict.t @@ -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 index 0000000..6a9cfcd --- /dev/null +++ b/t/strict_1.fail @@ -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 index 0000000..edbc47b --- /dev/null +++ b/t/strict_2.fail @@ -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 index 0000000..3560b99 --- /dev/null +++ b/t/strict_3.fail @@ -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 index 0000000..203afd5 --- /dev/null +++ b/t/strict_4.fail @@ -0,0 +1,7 @@ +#!perl +use warnings; +use strict; + +use Function::Parameters; + +fun bad_4(@y, @z) {}