t/55-eg: check example pages for warnings
authorMischa POSLAWSKY <perl@shiar.org>
Thu, 21 Nov 2013 22:02:14 +0000 (23:02 +0100)
committerMischa POSLAWSKY <perl@shiar.org>
Sat, 31 Mar 2018 20:58:53 +0000 (22:58 +0200)
Ensure sample code actually runs.

lib/Test/PLP.pm
t/55-eg.t [new file with mode: 0644]

index 04bfe2e9b21e29859c8c82f84e0c1d7fef97c405..519faca92e8dd1c8bfb073c21da06b0513c9a94f 100644 (file)
@@ -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 (file)
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, '<warning>', "$name no warnings");
+}
+