This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
testcase for change #27832
[perl5.git] / lib / Pod / t / text-options.t
CommitLineData
11f72409 1#!/usr/bin/perl -w
e2a52b10 2# $Id: text-options.t,v 1.6 2006-01-28 22:31:50 eagle Exp $
11f72409
RA
3#
4# text-options.t -- Additional tests for Pod::Text options.
5#
e2a52b10 6# Copyright 2002, 2004, 2006 by Russ Allbery <rra@stanford.edu>
11f72409
RA
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
RA
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";
e2a52b10
SP
48 open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n";
49 $parser->parse_from_file ('tmp.pod', \*OUT);
50 close OUT;
11f72409
RA
51 open (TMP, 'out.tmp') or die "Cannot open out.tmp: $!\n";
52 my $output;
53 {
54 local $/;
55 $output = <TMP>;
56 }
57 close TMP;
58 unlink ('tmp.pod', 'out.tmp');
59 my $expected = '';
60 while (<DATA>) {
61 last if $_ eq "###\n";
62 $expected .= $_;
63 }
64 if ($output eq $expected) {
65 print "ok $n\n";
66 } else {
67 print "not ok $n\n";
68 print "Expected\n========\n$expected\nOutput\n======\n$output\n";
69 }
70 $n++;
71}
72
73# Below the marker are bits of POD and corresponding expected text output.
74# This is used to test specific features or problems with Pod::Text. The
75# input and output are separated by lines containing only ###.
76
77__DATA__
78
79###
80alt 1
81###
82=head1 SAMPLE
83
84=over 4
85
86=item F
87
88Paragraph.
89
90=item Bar
91
92=item B
93
94Paragraph.
95
96=item Longer
97
98Paragraph.
99
100=back
101
102###
103
104==== SAMPLE ====
105
106: F Paragraph.
107
108: Bar
109: B Paragraph.
110
111: Longer
112 Paragraph.
113
114###
115
116###
117margin 4
118###
119=head1 SAMPLE
120
121This is some body text that is long enough to be a paragraph that wraps,
122thereby testing margins with wrapped paragraphs.
123
124 This is some verbatim text.
125
126=over 6
127
128=item Test
129
130This is a test of an indented paragraph.
131
132This is another indented paragraph.
133
134=back
135###
136 SAMPLE
137 This is some body text that is long enough to be a paragraph that
138 wraps, thereby testing margins with wrapped paragraphs.
139
140 This is some verbatim text.
141
142 Test This is a test of an indented paragraph.
143
144 This is another indented paragraph.
145
146###
b7ae008f
SP
147
148###
149code 1
150###
151This is some random text.
152This is more random text.
153
154This is some random text.
155This is more random text.
156
157=head1 SAMPLE
158
159This is POD.
160
161=cut
162
163This is more random text.
164###
165This is some random text.
166This is more random text.
167
168This is some random text.
169This is more random text.
170
171SAMPLE
172 This is POD.
173
174
175This is more random text.
176###
177
178###
179sentence 1
180###
181=head1 EXAMPLE
182
183Whitespace around C<< this. >> must be ignored per perlpodspec. >>
184needs to eat all of the space in front of it.
185
186=cut
187###
188EXAMPLE
189 Whitespace around "this." must be ignored per perlpodspec. >> needs to
190 eat all of the space in front of it.
191
192###