From fe22802045bae19ea53858a20b4752eb9e9bcac8 Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Thu, 21 Nov 2013 23:02:14 +0100 Subject: [PATCH] t/55-eg: check example pages for warnings Ensure sample code actually runs. --- lib/Test/PLP.pm | 3 ++- t/55-eg.t | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 t/55-eg.t 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"); +} + -- 2.30.0