"Fossies" - the Fresh Open Source Software Archive

Member "Module-Build-0.4224/t/pod_parser.t" (30 May 2017, 2835 Bytes) of package /linux/privat/Module-Build-0.4224.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/usr/bin/perl -w
    2 
    3 use strict;
    4 use lib 't/lib';
    5 use MBTest tests => 14;
    6 
    7 blib_load('Module::Build::PodParser');
    8 
    9 #########################
   10 
   11 {
   12   package IO::StringBased;
   13 
   14   sub TIEHANDLE {
   15     my ($class, $string) = @_;
   16     return bless {
   17           data => [ map "$_\n", split /\n/, $string],
   18          }, $class;
   19   }
   20 
   21   sub READLINE {
   22     shift @{ shift()->{data} };
   23   }
   24 }
   25 
   26 local *FH;
   27 tie *FH, 'IO::StringBased', <<'EOF';
   28 =head1 NAME
   29 
   30 Foo::Bar - Perl extension for blah blah blah
   31 
   32 =head1 AUTHOR
   33 
   34 C<Foo::Bar> was written by Engelbert Humperdinck I<E<lt>eh@example.comE<gt>> in 2004.
   35 
   36 Home page: http://example.com/~eh/
   37 
   38 =cut
   39 EOF
   40 
   41 
   42 my $pp = Module::Build::PodParser->new(fh => \*FH);
   43 ok $pp, 'object created';
   44 
   45 is $pp->get_author->[0], 'C<Foo::Bar> was written by Engelbert Humperdinck I<E<lt>eh@example.comE<gt>> in 2004.', 'author';
   46 is $pp->get_abstract, 'Perl extension for blah blah blah', 'abstract';
   47 
   48 
   49 {
   50   # Try again without a valid author spec
   51   untie *FH;
   52   tie *FH, 'IO::StringBased', <<'EOF';
   53 =head1 NAME
   54 
   55 Foo::Bar - Perl extension for blah blah blah
   56 
   57 =cut
   58 EOF
   59 
   60   my $pp = Module::Build::PodParser->new(fh => \*FH);
   61   ok $pp, 'object created';
   62 
   63   is_deeply $pp->get_author, [], 'author';
   64   is $pp->get_abstract, 'Perl extension for blah blah blah', 'abstract';
   65 }
   66 
   67 
   68 {
   69     # Try again with mixed-case =head1s.
   70   untie *FH;
   71   tie *FH, 'IO::StringBased', <<'EOF';
   72 =head1 Name
   73 
   74 Foo::Bar - Perl extension for blah blah blah
   75 
   76 =head1 Author
   77 
   78 C<Foo::Bar> was written by Engelbert Humperdinck I<E<lt>eh@example.comE<gt>> in 2004.
   79 
   80 Home page: http://example.com/~eh/
   81 
   82 =cut
   83 EOF
   84 
   85   my $pp = Module::Build::PodParser->new(fh => \*FH);
   86   ok $pp, 'object created';
   87 
   88   is $pp->get_author->[0], 'C<Foo::Bar> was written by Engelbert Humperdinck I<E<lt>eh@example.comE<gt>> in 2004.', 'author';
   89   is $pp->get_abstract, 'Perl extension for blah blah blah', 'abstract';
   90 }
   91 
   92 
   93 {
   94     # Now with C<Module::Name>
   95   untie *FH;
   96   tie *FH, 'IO::StringBased', <<'EOF';
   97 =head1 Name
   98 
   99 C<Foo::Bar> - Perl extension for blah blah blah
  100 
  101 =head1 Author
  102 
  103 C<Foo::Bar> was written by Engelbert Humperdinck I<E<lt>eh@example.comE<gt>> in 2004.
  104 
  105 Home page: http://example.com/~eh/
  106 
  107 =cut
  108 EOF
  109 
  110   my $pp = Module::Build::PodParser->new(fh => \*FH);
  111   ok $pp, 'object created';
  112 
  113   is $pp->get_author->[0], 'C<Foo::Bar> was written by Engelbert Humperdinck I<E<lt>eh@example.comE<gt>> in 2004.', 'author';
  114   is $pp->get_abstract, 'Perl extension for blah blah blah', 'abstract';
  115 }
  116 
  117 {
  118 local *FH;
  119 tie *FH, 'IO::StringBased', <<'EOF';
  120 =head1 NAME
  121 
  122 Foo_Bar - Perl extension for eating pie
  123 
  124 =head1 AUTHOR
  125 
  126 C<Foo_Bar> was written by Engelbert Humperdinck I<E<lt>eh@example.comE<gt>> in 2004.
  127 
  128 Home page: http://example.com/~eh/
  129 
  130 =cut
  131 EOF
  132 
  133 
  134   my $pp = Module::Build::PodParser->new(fh => \*FH);
  135   ok $pp, 'object created';
  136   is $pp->get_abstract, 'Perl extension for eating pie', 'abstract';
  137 }