Email change for Steven Schubiger
[p5sagit/p5-mst-13.2.git] / lib / Pod / t / text-options.t
CommitLineData
11f72409 1#!/usr/bin/perl -w
8f202758 2# $Id: text-options.t,v 1.5 2006-01-20 21:20:58 eagle Exp $
11f72409 3#
4# text-options.t -- Additional tests for Pod::Text options.
5#
b7ae008f 6# Copyright 2002, 2004 by Russ Allbery <rra@stanford.edu>
11f72409 7#
8# This program is free software; you may redistribute it and/or modify it
9# under the same terms as Perl itself.
10
11BEGIN {
12 chdir 't' if -d 't';
13 if ($ENV{PERL_CORE}) {
14 @INC = '../lib';
15 } else {
16 unshift (@INC, '../blib/lib');
17 }
18 unshift (@INC, '../blib/lib');
19 $| = 1;
b7ae008f 20 print "1..5\n";
11f72409 21}
22
23END {
24 print "not ok 1\n" unless $loaded;
25}
26
27use Pod::Text;
28
29$loaded = 1;
30print "ok 1\n";
31
32my $n = 2;
33while (<DATA>) {
34 my %options;
35 next until $_ eq "###\n";
36 while (<DATA>) {
37 last if $_ eq "###\n";
38 my ($option, $value) = split;
39 $options{$option} = $value;
40 }
41 open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n";
42 while (<DATA>) {
43 last if $_ eq "###\n";
44 print TMP $_;
45 }
46 close TMP;
47 my $parser = Pod::Text->new (%options) or die "Cannot create parser\n";
48 $parser->parse_from_file ('tmp.pod', 'out.tmp');
49 open (TMP, 'out.tmp') or die "Cannot open out.tmp: $!\n";
50 my $output;
51 {
52 local $/;
53 $output = <TMP>;
54 }
55 close TMP;
56 unlink ('tmp.pod', 'out.tmp');
57 my $expected = '';
58 while (<DATA>) {
59 last if $_ eq "###\n";
60 $expected .= $_;
61 }
62 if ($output eq $expected) {
63 print "ok $n\n";
64 } else {
65 print "not ok $n\n";
66 print "Expected\n========\n$expected\nOutput\n======\n$output\n";
67 }
68 $n++;
69}
70
71# Below the marker are bits of POD and corresponding expected text output.
72# This is used to test specific features or problems with Pod::Text. The
73# input and output are separated by lines containing only ###.
74
75__DATA__
76
77###
78alt 1
79###
80=head1 SAMPLE
81
82=over 4
83
84=item F
85
86Paragraph.
87
88=item Bar
89
90=item B
91
92Paragraph.
93
94=item Longer
95
96Paragraph.
97
98=back
99
100###
101
102==== SAMPLE ====
103
104: F Paragraph.
105
106: Bar
107: B Paragraph.
108
109: Longer
110 Paragraph.
111
112###
113
114###
115margin 4
116###
117=head1 SAMPLE
118
119This is some body text that is long enough to be a paragraph that wraps,
120thereby testing margins with wrapped paragraphs.
121
122 This is some verbatim text.
123
124=over 6
125
126=item Test
127
128This is a test of an indented paragraph.
129
130This is another indented paragraph.
131
132=back
133###
134 SAMPLE
135 This is some body text that is long enough to be a paragraph that
136 wraps, thereby testing margins with wrapped paragraphs.
137
138 This is some verbatim text.
139
140 Test This is a test of an indented paragraph.
141
142 This is another indented paragraph.
143
144###
b7ae008f 145
146###
147code 1
148###
149This is some random text.
150This is more random text.
151
152This is some random text.
153This is more random text.
154
155=head1 SAMPLE
156
157This is POD.
158
159=cut
160
161This is more random text.
162###
163This is some random text.
164This is more random text.
165
166This is some random text.
167This is more random text.
168
169SAMPLE
170 This is POD.
171
172
173This is more random text.
174###
175
176###
177sentence 1
178###
179=head1 EXAMPLE
180
181Whitespace around C<< this. >> must be ignored per perlpodspec. >>
182needs to eat all of the space in front of it.
183
184=cut
185###
186EXAMPLE
187 Whitespace around "this." must be ignored per perlpodspec. >> needs to
188 eat all of the space in front of it.
189
190###