script to run examples from documentation
authorMischa POSLAWSKY <perl@shiar.org>
Sat, 13 Mar 2021 03:54:50 +0000 (04:54 +0100)
committerMischa POSLAWSKY <perl@shiar.org>
Mon, 18 Apr 2022 09:04:29 +0000 (11:04 +0200)
t/examples.t [new file with mode: 0755]

diff --git a/t/examples.t b/t/examples.t
new file mode 100755 (executable)
index 0000000..19c1377
--- /dev/null
@@ -0,0 +1,20 @@
+#!/usr/bin/env perl
+use 5.014;
+use warnings;
+use Test::More;
+
+my $filename = 'barcat';
+open my $input, '<', $filename
+       or die "Cannot read documentation from $filename script\n";
+
+local $/ = "\n\n";
+while (readline $input) {
+       /^=head1 EXAMPLES/ ... /^=head1/ or next;
+       /^\h/ or next;
+       chomp;
+
+       my ($name) = /[\h(]*([^|]+)/;
+       ok(qx($_), $name);
+}
+
+done_testing();