summaryrefslogtreecommitdiff
path: root/lib/Pod
diff options
context:
space:
mode:
authorAbe Timmerman <abe@ztreet.demon.nl>2001-12-29 14:10:06 +0100
committerJarkko Hietaniemi <jhi@iki.fi>2001-12-29 15:30:14 +0000
commitda59c0190034bf333fe2137e3052714840ac574c (patch)
treeed96d1ffb52b9b1e3521ed71c90bcdcccd1097b6 /lib/Pod
parent7a3766701820dc204b97aa018956ce5ce6a8baf2 (diff)
downloadperl-da59c0190034bf333fe2137e3052714840ac574c.tar.gz
Message-ID: <cibr2u4f2ksggo4bgt8ijdkfn783avvvj4@4ax.com>
p4raw-id: //depot/perl@13928
Diffstat (limited to 'lib/Pod')
-rw-r--r--lib/Pod/t/InputObjects.t127
1 files changed, 127 insertions, 0 deletions
diff --git a/lib/Pod/t/InputObjects.t b/lib/Pod/t/InputObjects.t
new file mode 100644
index 0000000000..ad5bade601
--- /dev/null
+++ b/lib/Pod/t/InputObjects.t
@@ -0,0 +1,127 @@
+#!perl
+
+BEGIN {
+ chdir 't' if -d 't';
+ @INC = '../lib';
+}
+
+use Test::More;
+
+plan tests => 33;
+
+use_ok( 'Pod::InputObjects' );
+
+
+{ # test package Pod::InputSource
+ local *FH;
+ my $p_is = Pod::InputSource->new( -handle => \*FH );
+
+ isa_ok( $p_is, 'Pod::InputSource', 'Pod::InputSource constructor' );
+
+ is( $p_is->name, '(unknown)', 'Pod::InputSource->name()' );
+ is( $p_is->name( 'test' ), 'test', 'set Pod::InputSource->name( test )' );
+ is( $p_is->filename, 'test', 'Pod::InputSource->filename() alias' );
+
+ is( $p_is->handle, \*FH, 'Pod::InputSource->handle()' );
+
+ is( $p_is->was_cutting(), 0, 'Pod::InputSource->was_cutting()' );
+ is( $p_is->was_cutting( 1 ), 1, 'set Pod::InputSource->was_cutting( 1 )' );
+}
+
+{ # test package Pod::Paragraph
+ my $p_p1 = Pod::Paragraph->new( -text => 'NAME', -name => 'head2' );
+ my $p_p2 = Pod::Paragraph->new( 'test - This is the test suite' );
+ isa_ok( $p_p1, 'Pod::Paragraph', 'Pod::Paragraph constuctor' );
+ isa_ok( $p_p2, 'Pod::Paragraph', 'Pod::Paragraph constructor revisited' );
+
+ is( $p_p1->cmd_name(), 'head2', 'Pod::Paragraph->cmd_name()' );
+ is( $p_p1->cmd_name( 'head1' ), 'head1',
+ 'Pod::Paragraph->cmd_name( head1 )' );
+ is( $p_p2->cmd_name(), '',
+ 'Pod::Paragraph->cmd_name() revisited' );
+
+ is( $p_p1->text(), 'NAME', 'Pod::Paragraph->text()' );
+ is( $p_p2->text(), 'test - This is the test suite',
+ 'Pod::Paragraph->text() revisited' );
+ my $new_text = 'test - This is the test suite.';
+ is( $p_p2->text( $new_text ), $new_text,
+ 'Pod::Paragraph->text( ... )' );
+
+ is( $p_p1->raw_text, '=head1 NAME',
+ 'Pod::Paragraph->raw_text()' );
+ is( $p_p2->raw_text, $new_text,
+ 'Pod::Paragraph->raw_text() revisited' );
+
+ is( $p_p1->cmd_prefix, '=',
+ 'Pod::Paragraph->cmd_prefix()' );
+ is( $p_p1->cmd_separator, ' ',
+ 'Pod::Paragraph->cmd_separator()' );
+
+ # Pod::Parser->parse_tree() / ptree()
+
+ is( $p_p1->file_line(), '<unknown-file>:0',
+ 'Pod::Paragraph->file_line()' );
+ $p_p2->{ '-file' } = 'test'; $p_p2->{ '-line' } = 3;
+ is( $p_p2->file_line(), 'test:3',
+ 'Pod::Paragraph->file_line()' );
+}
+
+{ # test package Pod::InteriorSequence
+
+ my $p_pt = Pod::ParseTree->new();
+ my $pre_txt = 'test - This is the ';
+ my $cmd_txt = 'test suite';
+ my $pst_txt ='.';
+ $p_pt->append( $cmd_txt );
+
+ my $p_is = Pod::InteriorSequence->new(
+ -name => 'I', -ldelim => '<', -rdelim => '>',
+ -ptree => $p_pt
+ );
+ isa_ok( $p_is, 'Pod::InteriorSequence', 'P::InteriorSequence constructor' );
+
+ is( $p_is->cmd_name(), 'I', 'Pod::InteriorSequence->cmd_name()' );
+ is( $p_is->cmd_name( 'B' ), 'B',
+ 'set Pod::InteriorSequence->cmd_name( B )' );
+
+ is( $p_is->raw_text(), "B<$cmd_txt>",
+ 'Pod::InteriorSequence->raw_text()' );
+
+ $p_is->prepend( $pre_txt );
+ is( $p_is->raw_text(), "B<$pre_txt$cmd_txt>",
+ 'raw_text() after prepend()' );
+
+ $p_is->append( $pst_txt );
+ is( $p_is->raw_text(), "B<$pre_txt$cmd_txt$pst_txt>",
+ 'raw_text() after append()' );
+}
+
+{ # test package Pod::ParseTree
+ my $p_pt1 = Pod::ParseTree->new();
+ my $p_pt2 = Pod::ParseTree->new();
+ isa_ok( $p_pt1, 'Pod::ParseTree',
+ 'Pod::ParseTree constructor' );
+
+ is( $p_pt1->top(), $p_pt1, 'Pod::ParseTree->top()' );
+ is( $p_pt1->top( $p_pt1, $p_pt2 ), $p_pt1,
+ 'set new Pod::ParseTree->top()' );
+
+ ok( eq_array( [ $p_pt1->children() ], [ $p_pt1, $p_pt2] ),
+ 'Pod::ParseTree->children()' );
+
+ my $text = 'This is the test suite.';
+ $p_pt2->append( $text );
+ is( $p_pt2->raw_text(), $text, 'Pod::ParseTree->append()' );
+}
+
+__END__
+
+=head1 NAME
+
+InputObjects.t - The tests for Pod::InputObjects
+
+=head AUTHOR
+
+20011220 Abe Timmerman <abe@ztreet.demon.nl>
+
+=cut