From: Mischa POSLAWSKY Date: Thu, 21 Nov 2013 22:02:14 +0000 (+0100) Subject: t/55-eg: check example pages for warnings X-Git-Tag: 3.25~5 X-Git-Url: http://git.shiar.net/perl/plp/.git/commitdiff_plain/fe22802045bae19ea53858a20b4752eb9e9bcac8 t/55-eg: check example pages for warnings Ensure sample code actually runs. --- diff --git a/lib/Test/PLP.pm b/lib/Test/PLP.pm index 04bfe2e..519faca 100644 --- a/lib/Test/PLP.pm +++ b/lib/Test/PLP.pm @@ -101,7 +101,8 @@ sub plp_is { return is_string($output, $expect, $name); } - return $tb->ok(defined $output, $name); + $tb->ok(defined $output, $name); + return $output; } sub _getwarning { diff --git a/t/55-eg.t b/t/55-eg.t new file mode 100644 index 0000000..ed4bead --- /dev/null +++ b/t/55-eg.t @@ -0,0 +1,26 @@ +use strict; +use warnings; + +use File::Basename qw( dirname ); +use File::Spec; +use Test::More tests => 4; + +use_ok('Test::PLP'); + +sub lacks_string($$;$) { + unlike($_[0], qr/\Q$_[1]/, $_[2]); +} +eval { + Test::LongString->import('lacks_string'); # set up by Test::PLP +}; + +chdir File::Spec->catdir(dirname($0), '..', 'eg') + or BAIL_OUT('cannot change to test directory ../eg/'); + +for my $file (glob '*.plp') { + (my $name = $file) =~ s/[.][^.]+$//; + my $output = plp_is($file, undef, undef, undef, $name); + lacks_string($output, '"PLPerror"', "$name no errors"); + lacks_string($output, '', "$name no warnings"); +} +