12 use_ok( 'Pod::InputObjects' );
15 { # test package Pod::InputSource
17 my $p_is = Pod::InputSource->new( -handle => \*FH );
19 isa_ok( $p_is, 'Pod::InputSource', 'Pod::InputSource constructor' );
21 is( $p_is->name, '(unknown)', 'Pod::InputSource->name()' );
22 is( $p_is->name( 'test' ), 'test', 'set Pod::InputSource->name( test )' );
23 is( $p_is->filename, 'test', 'Pod::InputSource->filename() alias' );
25 is( $p_is->handle, \*FH, 'Pod::InputSource->handle()' );
27 is( $p_is->was_cutting(), 0, 'Pod::InputSource->was_cutting()' );
28 is( $p_is->was_cutting( 1 ), 1, 'set Pod::InputSource->was_cutting( 1 )' );
31 { # test package Pod::Paragraph
32 my $p_p1 = Pod::Paragraph->new( -text => 'NAME', -name => 'head2' );
33 my $p_p2 = Pod::Paragraph->new( 'test - This is the test suite' );
34 isa_ok( $p_p1, 'Pod::Paragraph', 'Pod::Paragraph constuctor' );
35 isa_ok( $p_p2, 'Pod::Paragraph', 'Pod::Paragraph constructor revisited' );
37 is( $p_p1->cmd_name(), 'head2', 'Pod::Paragraph->cmd_name()' );
38 is( $p_p1->cmd_name( 'head1' ), 'head1',
39 'Pod::Paragraph->cmd_name( head1 )' );
40 is( $p_p2->cmd_name(), '',
41 'Pod::Paragraph->cmd_name() revisited' );
43 is( $p_p1->text(), 'NAME', 'Pod::Paragraph->text()' );
44 is( $p_p2->text(), 'test - This is the test suite',
45 'Pod::Paragraph->text() revisited' );
46 my $new_text = 'test - This is the test suite.';
47 is( $p_p2->text( $new_text ), $new_text,
48 'Pod::Paragraph->text( ... )' );
50 is( $p_p1->raw_text, '=head1 NAME',
51 'Pod::Paragraph->raw_text()' );
52 is( $p_p2->raw_text, $new_text,
53 'Pod::Paragraph->raw_text() revisited' );
55 is( $p_p1->cmd_prefix, '=',
56 'Pod::Paragraph->cmd_prefix()' );
57 is( $p_p1->cmd_separator, ' ',
58 'Pod::Paragraph->cmd_separator()' );
60 # Pod::Parser->parse_tree() / ptree()
62 is( $p_p1->file_line(), '<unknown-file>:0',
63 'Pod::Paragraph->file_line()' );
64 $p_p2->{ '-file' } = 'test'; $p_p2->{ '-line' } = 3;
65 is( $p_p2->file_line(), 'test:3',
66 'Pod::Paragraph->file_line()' );
69 { # test package Pod::InteriorSequence
71 my $p_pt = Pod::ParseTree->new();
72 my $pre_txt = 'test - This is the ';
73 my $cmd_txt = 'test suite';
75 $p_pt->append( $cmd_txt );
77 my $p_is = Pod::InteriorSequence->new(
78 -name => 'I', -ldelim => '<', -rdelim => '>',
81 isa_ok( $p_is, 'Pod::InteriorSequence', 'P::InteriorSequence constructor' );
83 is( $p_is->cmd_name(), 'I', 'Pod::InteriorSequence->cmd_name()' );
84 is( $p_is->cmd_name( 'B' ), 'B',
85 'set Pod::InteriorSequence->cmd_name( B )' );
87 is( $p_is->raw_text(), "B<$cmd_txt>",
88 'Pod::InteriorSequence->raw_text()' );
90 $p_is->prepend( $pre_txt );
91 is( $p_is->raw_text(), "B<$pre_txt$cmd_txt>",
92 'raw_text() after prepend()' );
94 $p_is->append( $pst_txt );
95 is( $p_is->raw_text(), "B<$pre_txt$cmd_txt$pst_txt>",
96 'raw_text() after append()' );
99 { # test package Pod::ParseTree
100 my $p_pt1 = Pod::ParseTree->new();
101 my $p_pt2 = Pod::ParseTree->new();
102 isa_ok( $p_pt1, 'Pod::ParseTree',
103 'Pod::ParseTree constructor' );
105 is( $p_pt1->top(), $p_pt1, 'Pod::ParseTree->top()' );
106 is( $p_pt1->top( $p_pt1, $p_pt2 ), $p_pt1,
107 'set new Pod::ParseTree->top()' );
109 ok( eq_array( [ $p_pt1->children() ], [ $p_pt1, $p_pt2] ),
110 'Pod::ParseTree->children()' );
112 my $text = 'This is the test suite.';
113 $p_pt2->append( $text );
114 is( $p_pt2->raw_text(), $text, 'Pod::ParseTree->append()' );
121 InputObjects.t - The tests for Pod::InputObjects
125 20011220 Abe Timmerman <abe@ztreet.demon.nl>