pod_parser.t (Module-Build-0.4232) | : | pod_parser.t (Module-Build-0.4234) | ||
---|---|---|---|---|
#!/usr/bin/perl -w | #!/usr/bin/perl -w | |||
use strict; | use strict; | |||
use lib 't/lib'; | use lib 't/lib'; | |||
use MBTest tests => 14; | use MBTest tests => 16; | |||
use Encode 'encode'; | ||||
blib_load('Module::Build::PodParser'); | blib_load('Module::Build::PodParser'); | |||
######################### | ######################### | |||
{ | { | |||
package IO::StringBased; | open my $fh, '<', \<<'EOF'; | |||
sub TIEHANDLE { | ||||
my ($class, $string) = @_; | ||||
return bless { | ||||
data => [ map "$_\n", split /\n/, $string], | ||||
}, $class; | ||||
} | ||||
sub READLINE { | ||||
shift @{ shift()->{data} }; | ||||
} | ||||
} | ||||
local *FH; | ||||
tie *FH, 'IO::StringBased', <<'EOF'; | ||||
=head1 NAME | =head1 NAME | |||
Foo::Bar - Perl extension for blah blah blah | Foo::Bar - Perl extension for blah blah blah | |||
=head1 AUTHOR | =head1 AUTHOR | |||
C<Foo::Bar> was written by Engelbert Humperdinck I<E<lt>eh@example.comE<gt>> in 2004. | C<Foo::Bar> was written by Engelbert Humperdinck I<E<lt>eh@example.comE<gt>> in 2004. | |||
Home page: http://example.com/~eh/ | Home page: http://example.com/~eh/ | |||
=cut | =cut | |||
EOF | EOF | |||
my $pp = Module::Build::PodParser->new(fh => \*FH); | my $pp = Module::Build::PodParser->new(fh => $fh); | |||
ok $pp, 'object created'; | ok $pp, 'object created'; | |||
is $pp->get_author->[0], 'C<Foo::Bar> was written by Engelbert Humperdinck I<E<l t>eh@example.comE<gt>> in 2004.', 'author'; | is $pp->get_author->[0], 'C<Foo::Bar> was written by Engelbert Humperdinck I<E<l t>eh@example.comE<gt>> in 2004.', 'author'; | |||
is $pp->get_abstract, 'Perl extension for blah blah blah', 'abstract'; | is $pp->get_abstract, 'Perl extension for blah blah blah', 'abstract'; | |||
} | ||||
{ | { | |||
# Try again without a valid author spec | # Try again without a valid author spec | |||
untie *FH; | open my $fh, '<', \<<'EOF'; | |||
tie *FH, 'IO::StringBased', <<'EOF'; | ||||
=head1 NAME | =head1 NAME | |||
Foo::Bar - Perl extension for blah blah blah | Foo::Bar - Perl extension for blah blah blah | |||
=cut | =cut | |||
EOF | EOF | |||
my $pp = Module::Build::PodParser->new(fh => \*FH); | my $pp = Module::Build::PodParser->new(fh => $fh); | |||
ok $pp, 'object created'; | ok $pp, 'object created'; | |||
is_deeply $pp->get_author, [], 'author'; | is_deeply $pp->get_author, [], 'author'; | |||
is $pp->get_abstract, 'Perl extension for blah blah blah', 'abstract'; | is $pp->get_abstract, 'Perl extension for blah blah blah', 'abstract'; | |||
} | } | |||
{ | { | |||
# Try again with mixed-case =head1s. | # Try again with mixed-case =head1s. | |||
untie *FH; | open my $fh, '<', \<<'EOF'; | |||
tie *FH, 'IO::StringBased', <<'EOF'; | ||||
=head1 Name | =head1 Name | |||
Foo::Bar - Perl extension for blah blah blah | Foo::Bar - Perl extension for blah blah blah | |||
=head1 Author | =head1 Author | |||
C<Foo::Bar> was written by Engelbert Humperdinck I<E<lt>eh@example.comE<gt>> in 2004. | C<Foo::Bar> was written by Engelbert Humperdinck I<E<lt>eh@example.comE<gt>> in 2004. | |||
Home page: http://example.com/~eh/ | Home page: http://example.com/~eh/ | |||
=cut | =cut | |||
EOF | EOF | |||
my $pp = Module::Build::PodParser->new(fh => \*FH); | my $pp = Module::Build::PodParser->new(fh => $fh); | |||
ok $pp, 'object created'; | ok $pp, 'object created'; | |||
is $pp->get_author->[0], 'C<Foo::Bar> was written by Engelbert Humperdinck I<E <lt>eh@example.comE<gt>> in 2004.', 'author'; | is $pp->get_author->[0], 'C<Foo::Bar> was written by Engelbert Humperdinck I<E <lt>eh@example.comE<gt>> in 2004.', 'author'; | |||
is $pp->get_abstract, 'Perl extension for blah blah blah', 'abstract'; | is $pp->get_abstract, 'Perl extension for blah blah blah', 'abstract'; | |||
} | } | |||
{ | { | |||
# Now with C<Module::Name> | # Now with C<Module::Name> | |||
untie *FH; | open my $fh, '<', \<<'EOF'; | |||
tie *FH, 'IO::StringBased', <<'EOF'; | ||||
=head1 Name | =head1 Name | |||
C<Foo::Bar> - Perl extension for blah blah blah | C<Foo::Bar> - Perl extension for blah blah blah | |||
=head1 Author | =head1 Author | |||
C<Foo::Bar> was written by Engelbert Humperdinck I<E<lt>eh@example.comE<gt>> in 2004. | C<Foo::Bar> was written by Engelbert Humperdinck I<E<lt>eh@example.comE<gt>> in 2004. | |||
Home page: http://example.com/~eh/ | Home page: http://example.com/~eh/ | |||
=cut | =cut | |||
EOF | EOF | |||
my $pp = Module::Build::PodParser->new(fh => \*FH); | my $pp = Module::Build::PodParser->new(fh => $fh); | |||
ok $pp, 'object created'; | ok $pp, 'object created'; | |||
is $pp->get_author->[0], 'C<Foo::Bar> was written by Engelbert Humperdinck I<E <lt>eh@example.comE<gt>> in 2004.', 'author'; | is $pp->get_author->[0], 'C<Foo::Bar> was written by Engelbert Humperdinck I<E <lt>eh@example.comE<gt>> in 2004.', 'author'; | |||
is $pp->get_abstract, 'Perl extension for blah blah blah', 'abstract'; | is $pp->get_abstract, 'Perl extension for blah blah blah', 'abstract'; | |||
} | } | |||
{ | { | |||
local *FH; | open my $fh, '<', \<<'EOF'; | |||
tie *FH, 'IO::StringBased', <<'EOF'; | ||||
=head1 NAME | =head1 NAME | |||
Foo_Bar - Perl extension for eating pie | Foo_Bar - Perl extension for eating pie | |||
=head1 AUTHOR | =head1 AUTHOR | |||
C<Foo_Bar> was written by Engelbert Humperdinck I<E<lt>eh@example.comE<gt>> in 2 004. | C<Foo_Bar> was written by Engelbert Humperdinck I<E<lt>eh@example.comE<gt>> in 2 004. | |||
Home page: http://example.com/~eh/ | Home page: http://example.com/~eh/ | |||
=cut | =cut | |||
EOF | EOF | |||
my $pp = Module::Build::PodParser->new(fh => \*FH); | my $pp = Module::Build::PodParser->new(fh => $fh); | |||
ok $pp, 'object created'; | ok $pp, 'object created'; | |||
is $pp->get_abstract, 'Perl extension for eating pie', 'abstract'; | is $pp->get_abstract, 'Perl extension for eating pie', 'abstract'; | |||
} | } | |||
{ | ||||
open my $fh, '<', \ encode 'UTF-8', <<"EOF"; | ||||
=encoding utf8 | ||||
=head1 NAME | ||||
Foo_Bar - I \x{2764} Perl | ||||
=head1 AUTHOR | ||||
C<Foo_Bar> was written by Engelbert Humperdinck I<E<lt>eh\@example.comE<gt>> in | ||||
2004. | ||||
Home page: http://example.com/~eh/ | ||||
=cut | ||||
EOF | ||||
my $pp = Module::Build::PodParser->new(fh => $fh); | ||||
ok $pp, 'object created'; | ||||
is $pp->get_abstract, "I \x{2764} Perl", 'abstract with unicode'; | ||||
} | ||||
End of changes. 13 change blocks. | ||||
30 lines changed or deleted | 14 lines changed or added |