xref: /openbsd-src/gnu/usr.bin/perl/cpan/Module-Metadata/t/contains_pod.t (revision 9f11ffb7133c203312a01e4b986886bc88c7d74b)
16fb12b70Safresh1use strict;
26fb12b70Safresh1use warnings;
36fb12b70Safresh1use Test::More tests => 3;
46fb12b70Safresh1use Module::Metadata;
56fb12b70Safresh1
6b8851fccSafresh1BEGIN {
7*9f11ffb7Safresh1  *fh_from_string = "$]" < 5.008
86fb12b70Safresh1    ? require IO::Scalar && sub ($) {
96fb12b70Safresh1      IO::Scalar->new(\$_[0]);
106fb12b70Safresh1    }
11b8851fccSafresh1    # hide in an eval'd string so Perl::MinimumVersion doesn't clutch its pearls
12b8851fccSafresh1    : eval <<'EVAL'
13b8851fccSafresh1    sub ($) {
146fb12b70Safresh1      open my $fh, '<', \$_[0];
156fb12b70Safresh1      $fh
166fb12b70Safresh1    }
17b8851fccSafresh1EVAL
186fb12b70Safresh1  ;
19b8851fccSafresh1}
206fb12b70Safresh1
216fb12b70Safresh1{
226fb12b70Safresh1    my $src = <<'...';
236fb12b70Safresh1package Foo;
246fb12b70Safresh11;
256fb12b70Safresh1...
266fb12b70Safresh1
276fb12b70Safresh1    my $fh = fh_from_string($src);
286fb12b70Safresh1    my $module = Module::Metadata->new_from_handle($fh, 'Foo.pm');
296fb12b70Safresh1    ok(!$module->contains_pod(), 'This module does not contains POD');
306fb12b70Safresh1}
316fb12b70Safresh1
326fb12b70Safresh1{
336fb12b70Safresh1    my $src = <<'...';
346fb12b70Safresh1package Foo;
356fb12b70Safresh11;
366fb12b70Safresh1
376fb12b70Safresh1=head1 NAME
386fb12b70Safresh1
396fb12b70Safresh1Foo - bar
406fb12b70Safresh1...
416fb12b70Safresh1
426fb12b70Safresh1    my $fh = fh_from_string($src);
436fb12b70Safresh1    my $module = Module::Metadata->new_from_handle($fh, 'Foo.pm');
446fb12b70Safresh1    ok($module->contains_pod(), 'This module contains POD');
456fb12b70Safresh1}
466fb12b70Safresh1
476fb12b70Safresh1{
486fb12b70Safresh1    my $src = <<'...';
496fb12b70Safresh1package Foo;
506fb12b70Safresh11;
516fb12b70Safresh1
526fb12b70Safresh1=head1 NAME
536fb12b70Safresh1
546fb12b70Safresh1Foo - bar
556fb12b70Safresh1
566fb12b70Safresh1=head1 AUTHORS
576fb12b70Safresh1
586fb12b70Safresh1Tokuhiro Matsuno
596fb12b70Safresh1...
606fb12b70Safresh1
616fb12b70Safresh1    my $fh = fh_from_string($src);
626fb12b70Safresh1    my $module = Module::Metadata->new_from_handle($fh, 'Foo.pm');
636fb12b70Safresh1    ok($module->contains_pod(), 'This module contains POD');
646fb12b70Safresh1}
65