Add the original source packages to maemo, source lenny
[dh-make-perl] / dev / i386 / libmodule-build-perl / libmodule-build-perl-0.2808.01 / 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 => 7;
6
7 use Cwd ();
8 my $cwd = Cwd::cwd;
9
10 #########################
11
12 use_ok 'Module::Build::PodParser';
13
14 {
15   package IO::StringBased;
16   
17   sub TIEHANDLE {
18     my ($class, $string) = @_;
19     return bless {
20                   data => [ map "$_\n", split /\n/, $string],
21                  }, $class;
22   }
23   
24   sub READLINE {
25     shift @{ shift()->{data} };
26   }
27 }
28
29 local *FH;
30 tie *FH, 'IO::StringBased', <<'EOF';
31 =head1 NAME
32
33 Foo::Bar - Perl extension for blah blah blah
34
35 =head1 AUTHOR
36
37 C<Foo::Bar> was written by Engelbert Humperdinck I<E<lt>eh@example.comE<gt>> in 2004.
38
39 Home page: http://example.com/~eh/
40
41 =cut
42 EOF
43
44
45 my $pp = Module::Build::PodParser->new(fh => \*FH);
46 ok $pp, 'object created';
47
48 is $pp->get_author->[0], 'C<Foo::Bar> was written by Engelbert Humperdinck I<E<lt>eh@example.comE<gt>> in 2004.', 'author';
49 is $pp->get_abstract, 'Perl extension for blah blah blah', 'abstract';
50
51
52 {
53   # Try again without a valid author spec
54   untie *FH;
55   tie *FH, 'IO::StringBased', <<'EOF';
56 =head1 NAME
57
58 Foo::Bar - Perl extension for blah blah blah
59
60 =cut
61 EOF
62
63   my $pp = Module::Build::PodParser->new(fh => \*FH);
64   ok $pp, 'object created';
65   
66   is_deeply $pp->get_author, [], 'author';
67   is $pp->get_abstract, 'Perl extension for blah blah blah', 'abstract';
68 }
69
70