From: Lukas Mai Date: Tue, 2 Aug 2011 06:48:25 +0000 (+0200) Subject: test compilation failures harder X-Git-Tag: v0.05~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e2640c25d7b253410d5036898404b751ab745568;p=p5sagit%2FFunction-Parameters.git test compilation failures harder --- diff --git a/t/eating_strict_error.t b/t/eating_strict_error.t index 8b884d4..d9cf187 100644 --- a/t/eating_strict_error.t +++ b/t/eating_strict_error.t @@ -1,19 +1,20 @@ #!perl -use Test::More tests => 2; +use Test::More tests => 4; use warnings FATAL => 'all'; use strict; use Dir::Self; -#use Test::Fatal; +for my $thing (map [__DIR__ . "/eating_strict_error$_->[0].fail", @$_[1 .. $#$_]], ['', 5], ['_2', 8]) { + my ($file, $line) = @$thing; + my $done = do $file; + my $exc = $@; + my $err = $!; -my $file = __DIR__ . "/eating_strict_error.fail"; -my $done = do $file; -my $exc = $@; -my $err = $!; - -is $done, undef, "faulty code doesn't load"; -is $exc, qq{Global symbol "\$records" requires explicit package name at $file line 5.\nBEGIN not safe after errors--compilation aborted at $file line 9.\n}; -$exc or die "$file: $err"; + is $done, undef, "faulty code doesn't load"; + my $msg = qq{Global symbol "\$records" requires explicit package name at $file line $line.\n}; + like $exc, qr{^\Q$msg}; + $exc or die "$file: $err"; +} diff --git a/t/eating_strict_error_2.fail b/t/eating_strict_error_2.fail new file mode 100644 index 0000000..22cdfcf --- /dev/null +++ b/t/eating_strict_error_2.fail @@ -0,0 +1,11 @@ +use strict; +use Function::Parameters; + +fun get_ip( $agent ) { +} + +fun get_record( $agent, $target_name ) { + for my $record ( @$records ) { + } +} +