| 1 | #!perl
|
|---|
| 2 | use warnings;
|
|---|
| 3 | use strict;
|
|---|
| 4 |
|
|---|
| 5 | BEGIN {
|
|---|
| 6 | chdir 't' if -d 't';
|
|---|
| 7 | @INC = '../lib';
|
|---|
| 8 | };
|
|---|
| 9 |
|
|---|
| 10 | use Test::More tests => 9;
|
|---|
| 11 |
|
|---|
| 12 | require_ok( 'Pod::Select' );
|
|---|
| 13 |
|
|---|
| 14 | my $fake_out = tie *FAKEOUT, 'CatchOut';
|
|---|
| 15 |
|
|---|
| 16 | my $p_s = Pod::Select->new;
|
|---|
| 17 | isa_ok( $p_s, 'Pod::Select' );
|
|---|
| 18 |
|
|---|
| 19 | my $pod = << 'EO_NAME';
|
|---|
| 20 | =head1 NAME
|
|---|
| 21 |
|
|---|
| 22 | Select.t - Tests for Pod::Select.
|
|---|
| 23 |
|
|---|
| 24 | EO_NAME
|
|---|
| 25 |
|
|---|
| 26 | $p_s->select( 'NAME' );
|
|---|
| 27 | $p_s->parse_from_file( $0, \*FAKEOUT );
|
|---|
| 28 | is( $$fake_out, $pod, 'select( NAME )' );
|
|---|
| 29 |
|
|---|
| 30 | $pod .= << 'EO_SYNOPSIS';
|
|---|
| 31 | =head1 SYNOPSIS
|
|---|
| 32 |
|
|---|
| 33 | This program just tests the basics of the Pod::Select module.
|
|---|
| 34 |
|
|---|
| 35 | EO_SYNOPSIS
|
|---|
| 36 |
|
|---|
| 37 | $$fake_out = '';
|
|---|
| 38 | $p_s->select( 'NAME', 'SYNOPSIS' );
|
|---|
| 39 | $p_s->parse_from_file( $0, \*FAKEOUT );
|
|---|
| 40 | is( $$fake_out, $pod, 'select( NAME, SYNOPSIS )' );
|
|---|
| 41 |
|
|---|
| 42 | $pod .= << 'EO_AUTHOR';
|
|---|
| 43 | =head1 AUTHOR
|
|---|
| 44 |
|
|---|
| 45 | Abe Timmerman <[email protected]>
|
|---|
| 46 |
|
|---|
| 47 | EO_AUTHOR
|
|---|
| 48 |
|
|---|
| 49 | $$fake_out = '';
|
|---|
| 50 | $p_s->add_selection( 'AUTHOR' );
|
|---|
| 51 | $p_s->parse_from_file( $0, \*FAKEOUT );
|
|---|
| 52 | is( $$fake_out, $pod, 'add_selection( AUTHOR )' );
|
|---|
| 53 |
|
|---|
| 54 | my $head1 = $p_s->curr_headings(1);
|
|---|
| 55 | is( $head1, 'AUTHOR', 'curr_headings()' );
|
|---|
| 56 |
|
|---|
| 57 | $pod = << 'EO_DESCRIPTION';
|
|---|
| 58 | =head2 subsection
|
|---|
| 59 |
|
|---|
| 60 | a sub-section can be specified
|
|---|
| 61 |
|
|---|
| 62 | EO_DESCRIPTION
|
|---|
| 63 |
|
|---|
| 64 | $$fake_out = '';
|
|---|
| 65 | $p_s->select( 'DESCRIPTION/subsection' );
|
|---|
| 66 | $p_s->parse_from_file( $0, \*FAKEOUT );
|
|---|
| 67 | is( $$fake_out, $pod, 'select( DESCRIPTION/subsection )' );
|
|---|
| 68 |
|
|---|
| 69 |
|
|---|
| 70 | ok( $p_s->match_section( 'DESCRIPTION', 'subsection' ),
|
|---|
| 71 | 'match_section( DESCRIPTION, subsection )' );
|
|---|
| 72 |
|
|---|
| 73 | $pod = << 'EO_DESCRIPTION';
|
|---|
| 74 | =head1 DESCRIPTION
|
|---|
| 75 |
|
|---|
| 76 | I'll go by the POD in Pod::Select.
|
|---|
| 77 |
|
|---|
| 78 | EO_DESCRIPTION
|
|---|
| 79 |
|
|---|
| 80 | $$fake_out = '';
|
|---|
| 81 | $p_s->select( 'DESCRIPTION/!.+' );
|
|---|
| 82 | $p_s->parse_from_file( $0, \*FAKEOUT );
|
|---|
| 83 | is( $$fake_out, $pod, 'select( DESCRIPTION/!.+ )' );
|
|---|
| 84 |
|
|---|
| 85 |
|
|---|
| 86 | package CatchOut;
|
|---|
| 87 | sub TIEHANDLE { bless \( my $self ), shift }
|
|---|
| 88 | sub PRINT { my $self = shift; $$self .= $_[0] }
|
|---|
| 89 |
|
|---|
| 90 | __END__
|
|---|
| 91 |
|
|---|
| 92 | =head1 NAME
|
|---|
| 93 |
|
|---|
| 94 | Select.t - Tests for Pod::Select.
|
|---|
| 95 |
|
|---|
| 96 | =head1 SYNOPSIS
|
|---|
| 97 |
|
|---|
| 98 | This program just tests the basics of the Pod::Select module.
|
|---|
| 99 |
|
|---|
| 100 | =head1 DESCRIPTION
|
|---|
| 101 |
|
|---|
| 102 | I'll go by the POD in Pod::Select.
|
|---|
| 103 |
|
|---|
| 104 | =head2 selection + add_selection
|
|---|
| 105 |
|
|---|
| 106 | Pull out the specified sections
|
|---|
| 107 |
|
|---|
| 108 | =head2 subsection
|
|---|
| 109 |
|
|---|
| 110 | a sub-section can be specified
|
|---|
| 111 |
|
|---|
| 112 | =head1 AUTHOR
|
|---|
| 113 |
|
|---|
| 114 | Abe Timmerman <[email protected]>
|
|---|
| 115 |
|
|---|
| 116 | =cut
|
|---|