Add ExtUtils::Miniperl to the list of core modules for all versions >= 5.00504
[p5sagit/p5-mst-13.2.git] / lib / Module / Build / t / pod_parser.t
1 #!/usr/bin/perl -w
2
3 use strict;
4 use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib';
5 use MBTest tests => 8;
6
7 use_ok 'Module::Build::PodParser';
8 ensure_blib('Module::Build::PodParser');
9
10 #########################
11
12 {
13   package IO::StringBased;
14   
15   sub TIEHANDLE {
16     my ($class, $string) = @_;
17     return bless {
18                   data => [ map "$_\n", split /\n/, $string],
19                  }, $class;
20   }
21   
22   sub READLINE {
23     shift @{ shift()->{data} };
24   }
25 }
26
27 local *FH;
28 tie *FH, 'IO::StringBased', <<'EOF';
29 =head1 NAME
30
31 Foo::Bar - Perl extension for blah blah blah
32
33 =head1 AUTHOR
34
35 C<Foo::Bar> was written by Engelbert Humperdinck I<E<lt>eh@example.comE<gt>> in 2004.
36
37 Home page: http://example.com/~eh/
38
39 =cut
40 EOF
41
42
43 my $pp = Module::Build::PodParser->new(fh => \*FH);
44 ok $pp, 'object created';
45
46 is $pp->get_author->[0], 'C<Foo::Bar> was written by Engelbert Humperdinck I<E<lt>eh@example.comE<gt>> in 2004.', 'author';
47 is $pp->get_abstract, 'Perl extension for blah blah blah', 'abstract';
48
49
50 {
51   # Try again without a valid author spec
52   untie *FH;
53   tie *FH, 'IO::StringBased', <<'EOF';
54 =head1 NAME
55
56 Foo::Bar - Perl extension for blah blah blah
57
58 =cut
59 EOF
60
61   my $pp = Module::Build::PodParser->new(fh => \*FH);
62   ok $pp, 'object created';
63   
64   is_deeply $pp->get_author, [], 'author';
65   is $pp->get_abstract, 'Perl extension for blah blah blah', 'abstract';
66 }
67
68