contains_pod.t revision 1.3
1use strict; 2use warnings; 3use Test::More tests => 3; 4use Module::Metadata; 5 6BEGIN { 7 *fh_from_string = "$]" < 5.008 8 ? require IO::Scalar && sub ($) { 9 IO::Scalar->new(\$_[0]); 10 } 11 # hide in an eval'd string so Perl::MinimumVersion doesn't clutch its pearls 12 : eval <<'EVAL' 13 sub ($) { 14 open my $fh, '<', \$_[0]; 15 $fh 16 } 17EVAL 18 ; 19} 20 21{ 22 my $src = <<'...'; 23package Foo; 241; 25... 26 27 my $fh = fh_from_string($src); 28 my $module = Module::Metadata->new_from_handle($fh, 'Foo.pm'); 29 ok(!$module->contains_pod(), 'This module does not contains POD'); 30} 31 32{ 33 my $src = <<'...'; 34package Foo; 351; 36 37=head1 NAME 38 39Foo - bar 40... 41 42 my $fh = fh_from_string($src); 43 my $module = Module::Metadata->new_from_handle($fh, 'Foo.pm'); 44 ok($module->contains_pod(), 'This module contains POD'); 45} 46 47{ 48 my $src = <<'...'; 49package Foo; 501; 51 52=head1 NAME 53 54Foo - bar 55 56=head1 AUTHORS 57 58Tokuhiro Matsuno 59... 60 61 my $fh = fh_from_string($src); 62 my $module = Module::Metadata->new_from_handle($fh, 'Foo.pm'); 63 ok($module->contains_pod(), 'This module contains POD'); 64} 65