1*0Sstevel@tonic-gate#!perl -Tw 2*0Sstevel@tonic-gate 3*0Sstevel@tonic-gateBEGIN { 4*0Sstevel@tonic-gate chdir 't' if -d 't'; 5*0Sstevel@tonic-gate @INC = '../lib'; 6*0Sstevel@tonic-gate} 7*0Sstevel@tonic-gate 8*0Sstevel@tonic-gateuse Test::More; 9*0Sstevel@tonic-gate 10*0Sstevel@tonic-gateplan tests => 33; 11*0Sstevel@tonic-gate 12*0Sstevel@tonic-gateuse_ok( 'Pod::InputObjects' ); 13*0Sstevel@tonic-gate 14*0Sstevel@tonic-gate 15*0Sstevel@tonic-gate{ # test package Pod::InputSource 16*0Sstevel@tonic-gate local *FH; 17*0Sstevel@tonic-gate my $p_is = Pod::InputSource->new( -handle => \*FH ); 18*0Sstevel@tonic-gate 19*0Sstevel@tonic-gate isa_ok( $p_is, 'Pod::InputSource', 'Pod::InputSource constructor' ); 20*0Sstevel@tonic-gate 21*0Sstevel@tonic-gate is( $p_is->name, '(unknown)', 'Pod::InputSource->name()' ); 22*0Sstevel@tonic-gate is( $p_is->name( 'test' ), 'test', 'set Pod::InputSource->name( test )' ); 23*0Sstevel@tonic-gate is( $p_is->filename, 'test', 'Pod::InputSource->filename() alias' ); 24*0Sstevel@tonic-gate 25*0Sstevel@tonic-gate is( $p_is->handle, \*FH, 'Pod::InputSource->handle()' ); 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate is( $p_is->was_cutting(), 0, 'Pod::InputSource->was_cutting()' ); 28*0Sstevel@tonic-gate is( $p_is->was_cutting( 1 ), 1, 'set Pod::InputSource->was_cutting( 1 )' ); 29*0Sstevel@tonic-gate} 30*0Sstevel@tonic-gate 31*0Sstevel@tonic-gate{ # test package Pod::Paragraph 32*0Sstevel@tonic-gate my $p_p1 = Pod::Paragraph->new( -text => 'NAME', -name => 'head2' ); 33*0Sstevel@tonic-gate my $p_p2 = Pod::Paragraph->new( 'test - This is the test suite' ); 34*0Sstevel@tonic-gate isa_ok( $p_p1, 'Pod::Paragraph', 'Pod::Paragraph constuctor' ); 35*0Sstevel@tonic-gate isa_ok( $p_p2, 'Pod::Paragraph', 'Pod::Paragraph constructor revisited' ); 36*0Sstevel@tonic-gate 37*0Sstevel@tonic-gate is( $p_p1->cmd_name(), 'head2', 'Pod::Paragraph->cmd_name()' ); 38*0Sstevel@tonic-gate is( $p_p1->cmd_name( 'head1' ), 'head1', 39*0Sstevel@tonic-gate 'Pod::Paragraph->cmd_name( head1 )' ); 40*0Sstevel@tonic-gate cmp_ok( $p_p2->cmd_name(), 'eq', '', 41*0Sstevel@tonic-gate 'Pod::Paragraph->cmd_name() revisited' ); 42*0Sstevel@tonic-gate 43*0Sstevel@tonic-gate is( $p_p1->text(), 'NAME', 'Pod::Paragraph->text()' ); 44*0Sstevel@tonic-gate is( $p_p2->text(), 'test - This is the test suite', 45*0Sstevel@tonic-gate 'Pod::Paragraph->text() revisited' ); 46*0Sstevel@tonic-gate my $new_text = 'test - This is the test suite.'; 47*0Sstevel@tonic-gate is( $p_p2->text( $new_text ), $new_text, 48*0Sstevel@tonic-gate 'Pod::Paragraph->text( ... )' ); 49*0Sstevel@tonic-gate 50*0Sstevel@tonic-gate is( $p_p1->raw_text, '=head1 NAME', 51*0Sstevel@tonic-gate 'Pod::Paragraph->raw_text()' ); 52*0Sstevel@tonic-gate is( $p_p2->raw_text, $new_text, 53*0Sstevel@tonic-gate 'Pod::Paragraph->raw_text() revisited' ); 54*0Sstevel@tonic-gate 55*0Sstevel@tonic-gate is( $p_p1->cmd_prefix, '=', 56*0Sstevel@tonic-gate 'Pod::Paragraph->cmd_prefix()' ); 57*0Sstevel@tonic-gate is( $p_p1->cmd_separator, ' ', 58*0Sstevel@tonic-gate 'Pod::Paragraph->cmd_separator()' ); 59*0Sstevel@tonic-gate 60*0Sstevel@tonic-gate # Pod::Parser->parse_tree() / ptree() 61*0Sstevel@tonic-gate 62*0Sstevel@tonic-gate is( $p_p1->file_line(), '<unknown-file>:0', 63*0Sstevel@tonic-gate 'Pod::Paragraph->file_line()' ); 64*0Sstevel@tonic-gate $p_p2->{ '-file' } = 'test'; $p_p2->{ '-line' } = 3; 65*0Sstevel@tonic-gate is( $p_p2->file_line(), 'test:3', 66*0Sstevel@tonic-gate 'Pod::Paragraph->file_line()' ); 67*0Sstevel@tonic-gate} 68*0Sstevel@tonic-gate 69*0Sstevel@tonic-gate{ # test package Pod::InteriorSequence 70*0Sstevel@tonic-gate 71*0Sstevel@tonic-gate my $p_pt = Pod::ParseTree->new(); 72*0Sstevel@tonic-gate my $pre_txt = 'test - This is the '; 73*0Sstevel@tonic-gate my $cmd_txt = 'test suite'; 74*0Sstevel@tonic-gate my $pst_txt ='.'; 75*0Sstevel@tonic-gate $p_pt->append( $cmd_txt ); 76*0Sstevel@tonic-gate 77*0Sstevel@tonic-gate my $p_is = Pod::InteriorSequence->new( 78*0Sstevel@tonic-gate -name => 'I', -ldelim => '<', -rdelim => '>', 79*0Sstevel@tonic-gate -ptree => $p_pt 80*0Sstevel@tonic-gate ); 81*0Sstevel@tonic-gate isa_ok( $p_is, 'Pod::InteriorSequence', 'P::InteriorSequence constructor' ); 82*0Sstevel@tonic-gate 83*0Sstevel@tonic-gate is( $p_is->cmd_name(), 'I', 'Pod::InteriorSequence->cmd_name()' ); 84*0Sstevel@tonic-gate is( $p_is->cmd_name( 'B' ), 'B', 85*0Sstevel@tonic-gate 'set Pod::InteriorSequence->cmd_name( B )' ); 86*0Sstevel@tonic-gate 87*0Sstevel@tonic-gate is( $p_is->raw_text(), "B<$cmd_txt>", 88*0Sstevel@tonic-gate 'Pod::InteriorSequence->raw_text()' ); 89*0Sstevel@tonic-gate 90*0Sstevel@tonic-gate $p_is->prepend( $pre_txt ); 91*0Sstevel@tonic-gate is( $p_is->raw_text(), "B<$pre_txt$cmd_txt>", 92*0Sstevel@tonic-gate 'raw_text() after prepend()' ); 93*0Sstevel@tonic-gate 94*0Sstevel@tonic-gate $p_is->append( $pst_txt ); 95*0Sstevel@tonic-gate is( $p_is->raw_text(), "B<$pre_txt$cmd_txt$pst_txt>", 96*0Sstevel@tonic-gate 'raw_text() after append()' ); 97*0Sstevel@tonic-gate} 98*0Sstevel@tonic-gate 99*0Sstevel@tonic-gate{ # test package Pod::ParseTree 100*0Sstevel@tonic-gate my $p_pt1 = Pod::ParseTree->new(); 101*0Sstevel@tonic-gate my $p_pt2 = Pod::ParseTree->new(); 102*0Sstevel@tonic-gate isa_ok( $p_pt1, 'Pod::ParseTree', 103*0Sstevel@tonic-gate 'Pod::ParseTree constructor' ); 104*0Sstevel@tonic-gate 105*0Sstevel@tonic-gate is( $p_pt1->top(), $p_pt1, 'Pod::ParseTree->top()' ); 106*0Sstevel@tonic-gate is( $p_pt1->top( $p_pt1, $p_pt2 ), $p_pt1, 107*0Sstevel@tonic-gate 'set new Pod::ParseTree->top()' ); 108*0Sstevel@tonic-gate 109*0Sstevel@tonic-gate ok( eq_array( [ $p_pt1->children() ], [ $p_pt1, $p_pt2] ), 110*0Sstevel@tonic-gate 'Pod::ParseTree->children()' ); 111*0Sstevel@tonic-gate 112*0Sstevel@tonic-gate my $text = 'This is the test suite.'; 113*0Sstevel@tonic-gate $p_pt2->append( $text ); 114*0Sstevel@tonic-gate is( $p_pt2->raw_text(), $text, 'Pod::ParseTree->append()' ); 115*0Sstevel@tonic-gate} 116*0Sstevel@tonic-gate 117*0Sstevel@tonic-gate__END__ 118*0Sstevel@tonic-gate 119*0Sstevel@tonic-gate=head1 NAME 120*0Sstevel@tonic-gate 121*0Sstevel@tonic-gateInputObjects.t - The tests for Pod::InputObjects 122*0Sstevel@tonic-gate 123*0Sstevel@tonic-gate=head AUTHOR 124*0Sstevel@tonic-gate 125*0Sstevel@tonic-gate20011220 Abe Timmerman <abe@ztreet.demon.nl> 126*0Sstevel@tonic-gate 127*0Sstevel@tonic-gate=cut 128