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