1#!perl -Tw
2
3BEGIN {
4	chdir 't' if -d 't';
5	@INC = '../lib';
6}
7
8use Test::More;
9
10plan tests => 33;
11
12use_ok( 'Pod::InputObjects' );
13
14
15{ # test package Pod::InputSource
16    local *FH;
17    my $p_is = Pod::InputSource->new( -handle => \*FH );
18
19    isa_ok( $p_is, 'Pod::InputSource', 'Pod::InputSource constructor' );
20
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' );
24
25    is( $p_is->handle, \*FH, 'Pod::InputSource->handle()' );
26
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 )' );
29}
30
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' );
36
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    cmp_ok( $p_p2->cmd_name(), 'eq', '',
41        'Pod::Paragraph->cmd_name() revisited' );
42
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( ... )' );
49    
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' );
54    
55    is( $p_p1->cmd_prefix, '=', 
56        'Pod::Paragraph->cmd_prefix()' );
57    is( $p_p1->cmd_separator, ' ', 
58        'Pod::Paragraph->cmd_separator()' );
59
60    # Pod::Parser->parse_tree() / ptree()
61    
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()' );
67}
68
69{ # test package Pod::InteriorSequence
70
71    my $p_pt = Pod::ParseTree->new();
72    my $pre_txt = 'test - This is the ';
73    my $cmd_txt = 'test suite';
74    my $pst_txt ='.';
75	$p_pt->append( $cmd_txt );
76
77    my $p_is = Pod::InteriorSequence->new( 
78        -name => 'I', -ldelim => '<', -rdelim => '>',
79        -ptree => $p_pt
80    );
81    isa_ok( $p_is, 'Pod::InteriorSequence', 'P::InteriorSequence constructor' );
82	
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 )' );
86
87    is( $p_is->raw_text(), "B<$cmd_txt>", 
88        'Pod::InteriorSequence->raw_text()' );
89
90    $p_is->prepend( $pre_txt );
91    is( $p_is->raw_text(), "B<$pre_txt$cmd_txt>", 
92        'raw_text() after prepend()' );
93
94    $p_is->append( $pst_txt );
95    is( $p_is->raw_text(), "B<$pre_txt$cmd_txt$pst_txt>",
96        'raw_text() after append()' );    
97}
98
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' );
104    
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()' );
108
109    ok( eq_array( [ $p_pt1->children() ], [ $p_pt1, $p_pt2] ),
110        'Pod::ParseTree->children()' );
111
112	my $text = 'This is the test suite.';
113	$p_pt2->append( $text );
114	is( $p_pt2->raw_text(), $text, 'Pod::ParseTree->append()' );
115}
116
117__END__
118
119=head1 NAME
120
121InputObjects.t - The tests for Pod::InputObjects
122
123=head AUTHOR
124
12520011220 Abe Timmerman <abe@ztreet.demon.nl>
126
127=cut
128