This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Upgrade to podlators 2.0.5
[perl5.git] / lib / Pod / t / man.t
1 #!/usr/bin/perl -w
2 # $Id: man.t,v 1.10 2006-09-16 20:25:25 eagle Exp $
3 #
4 # man.t -- Additional specialized tests for Pod::Man.
5 #
6 # Copyright 2002, 2003, 2004, 2006 by Russ Allbery <rra@stanford.edu>
7 #
8 # This program is free software; you may redistribute it and/or modify it
9 # under the same terms as Perl itself.
10
11 BEGIN {
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;
20     print "1..21\n";
21 }
22
23 END {
24     print "not ok 1\n" unless $loaded;
25 }
26
27 use Pod::Man;
28
29 $loaded = 1;
30 print "ok 1\n";
31
32 my $parser = Pod::Man->new or die "Cannot create parser\n";
33 my $n = 2;
34 while (<DATA>) {
35     next until $_ eq "###\n";
36     open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n";
37
38     # We have a test in ISO 8859-1 encoding.  Make sure that nothing strange
39     # happens if Perl thinks the world is Unicode.  Wrap this in eval so that
40     # older versions of Perl don't croak.
41     eval { binmode (\*TMP, ':encoding(iso-8859-1)') };
42
43     while (<DATA>) {
44         last if $_ eq "###\n";
45         print TMP $_;
46     }
47     close TMP;
48     open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n";
49     $parser->parse_from_file ('tmp.pod', \*OUT);
50     close OUT;
51     open (OUT, 'out.tmp') or die "Cannot open out.tmp: $!\n";
52     while (<OUT>) { last if /^\.nh/ }
53     my $output;
54     {
55         local $/;
56         $output = <OUT>;
57     }
58     close OUT;
59     unlink ('tmp.pod', 'out.tmp');
60     my $expected = '';
61     while (<DATA>) {
62         last if $_ eq "###\n";
63         $expected .= $_;
64     }
65     if ($output eq $expected) {
66         print "ok $n\n";
67     } else {
68         print "not ok $n\n";
69         print "Expected\n========\n$expected\nOutput\n======\n$output\n";
70     }
71     $n++;
72 }
73
74 # Below the marker are bits of POD and corresponding expected nroff output.
75 # This is used to test specific features or problems with Pod::Man.  The input
76 # and output are separated by lines containing only ###.
77
78 __DATA__
79
80 ###
81 =head1 NAME
82
83 gcc - GNU project C and C++ compiler
84
85 =head1 C++ NOTES
86
87 Other mentions of C++.
88 ###
89 .SH "NAME"
90 gcc \- GNU project C and C++ compiler
91 .SH "\*(C+ NOTES"
92 .IX Header " NOTES"
93 Other mentions of \*(C+.
94 ###
95
96 ###
97 =head1 PERIODS
98
99 This C<.> should be quoted.
100 ###
101 .SH "PERIODS"
102 .IX Header "PERIODS"
103 This \f(CW\*(C`.\*(C'\fR should be quoted.
104 ###
105
106 ###
107 =over 4
108
109 =item *
110
111 A bullet.
112
113 =item    *
114
115 Another bullet.
116
117 =item * Also a bullet.
118
119 =back
120 ###
121 .IP "\(bu" 4
122 A bullet.
123 .IP "\(bu" 4
124 Another bullet.
125 .IP "\(bu" 4
126 Also a bullet.
127 ###
128
129 ###
130 =over 4
131
132 =item foo
133
134 Not a bullet.
135
136 =item *
137
138 Also not a bullet.
139
140 =back
141 ###
142 .IP "foo" 4
143 .IX Item "foo"
144 Not a bullet.
145 .IP "*" 4
146 Also not a bullet.
147 ###
148
149 ###
150 =encoding iso-8859-1
151
152 =head1 ACCENTS
153
154 Beyoncé!  Beyoncé!  Beyoncé!!
155
156     Beyoncé!  Beyoncé!
157       Beyoncé!  Beyoncé!
158         Beyoncé!  Beyoncé!
159
160 Older versions didn't convert Beyoncé in verbatim.
161 ###
162 .SH "ACCENTS"
163 .IX Header "ACCENTS"
164 Beyonce\*'!  Beyonce\*'!  Beyonce\*'!!
165 .PP
166 .Vb 3
167 \&    Beyonce\*'!  Beyonce\*'!
168 \&      Beyonce\*'!  Beyonce\*'!
169 \&        Beyonce\*'!  Beyonce\*'!
170 .Ve
171 .PP
172 Older versions didn't convert Beyonce\*' in verbatim.
173 ###
174
175 ###
176 =over 4
177
178 =item 1. Not a number
179
180 =item 2. Spaced right
181
182 =back
183
184 =over 2
185
186 =item 1 Not a number
187
188 =item 2 Spaced right
189
190 =back
191 ###
192 .IP "1. Not a number" 4
193 .IX Item "1. Not a number"
194 .PD 0
195 .IP "2. Spaced right" 4
196 .IX Item "2. Spaced right"
197 .IP "1 Not a number" 2
198 .IX Item "1 Not a number"
199 .IP "2 Spaced right" 2
200 .IX Item "2 Spaced right"
201 ###
202
203 ###
204 =over 4
205
206 =item Z<>*
207
208 Not bullet.
209
210 =back
211 ###
212 .IP "*" 4
213 Not bullet.
214 ###
215
216 ###
217 =head1 SEQS
218
219 "=over ... Z<>=back"
220
221 "SE<lt>...E<gt>"
222
223 The quotes should be converted in the above to paired quotes.
224 ###
225 .SH "SEQS"
226 .IX Header "SEQS"
227 \&\*(L"=over ... =back\*(R"
228 .PP
229 \&\*(L"S<...>\*(R"
230 .PP
231 The quotes should be converted in the above to paired quotes.
232 ###
233
234 ###
235 =head1 YEN
236
237 It cost me E<165>12345! That should be an X.
238 ###
239 .SH "YEN"
240 .IX Header "YEN"
241 It cost me X12345! That should be an X.
242 ###
243
244 ###
245 =head1 agrave
246
247 Open E<agrave> la shell. Previous versions mapped it wrong.
248 ###
249 .SH "agrave"
250 .IX Header "agrave"
251 Open a\*` la shell. Previous versions mapped it wrong.
252 ###
253
254 ###
255 =over
256
257 =item First level
258
259 Blah blah blah....
260
261 =over
262
263 =item *
264
265 Should be a bullet.
266
267 =back
268
269 =back
270 ###
271 .IP "First level" 4
272 .IX Item "First level"
273 Blah blah blah....
274 .RS 4
275 .IP "\(bu" 4
276 Should be a bullet.
277 .RE
278 .RS 4
279 .RE
280 ###
281
282 ###
283 =over 4
284
285 =item 1. Check fonts in @CARP_NOT test.
286
287 =back
288 ###
289 .ie n .IP "1. Check fonts in @CARP_NOT test." 4
290 .el .IP "1. Check fonts in \f(CW@CARP_NOT\fR test." 4
291 .IX Item "1. Check fonts in @CARP_NOT test."
292 ###
293
294 ###
295 =head1 LINK QUOTING
296
297 There should not be double quotes: L<C<< (?>pattern) >>>.
298 ###
299 .SH "LINK QUOTING"
300 .IX Header "LINK QUOTING"
301 There should not be double quotes: \f(CW\*(C`(?>pattern)\*(C'\fR.
302 ###
303
304 ###
305 =head1 SE<lt>E<gt> MAGIC
306
307 Magic should be applied S<RISC OS> to that.
308 ###
309 .SH "S<> MAGIC"
310 .IX Header "S<> MAGIC"
311 Magic should be applied \s-1RISC\s0\ \s-1OS\s0 to that.
312 ###
313
314 ###
315 =head1 MAGIC MONEY
316
317 These should be identical.
318
319 Bippity boppity boo "The
320 price is $Z<>100."
321
322 Bippity boppity boo "The
323 price is $100."
324 ###
325 .SH "MAGIC MONEY"
326 .IX Header "MAGIC MONEY"
327 These should be identical.
328 .PP
329 Bippity boppity boo \*(L"The
330 price is \f(CW$100\fR.\*(R"
331 .PP
332 Bippity boppity boo \*(L"The
333 price is \f(CW$100\fR.\*(R"
334 ###
335
336 ###
337 =head1 NAME
338
339 "Stuff" (no guesswork)
340
341 =head2 THINGS
342
343 Oboy, is this C++ "fun" yet! (guesswork)
344 ###
345 .SH "NAME"
346 "Stuff" (no guesswork)
347 .Sh "\s-1THINGS\s0"
348 .IX Subsection "THINGS"
349 Oboy, is this \*(C+ \*(L"fun\*(R" yet! (guesswork)
350 ###
351
352 ###
353 =head1 Newline C Quote Weirdness
354
355 Blorp C<'
356 ''>. Yes.
357 ###
358 .SH "Newline C Quote Weirdness"
359 .IX Header "Newline C Quote Weirdness"
360 Blorp \f(CW'
361 \&''\fR. Yes.
362 ###
363
364 ###
365 =head1 Soft Hypen Testing
366
367 sigE<shy>action
368 manuE<shy>script
369 JarkE<shy>ko HieE<shy>taE<shy>nieE<shy>mi
370
371 And again:
372
373 sigE<173>action
374 manuE<173>script
375 JarkE<173>ko HieE<173>taE<173>nieE<173>mi
376
377 And one more time:
378
379 sigE<0x00AD>action
380 manuE<0x00AD>script
381 JarkE<0x00AD>ko HieE<0x00AD>taE<0x00AD>nieE<0x00AD>mi
382 ###
383 .SH "Soft Hypen Testing"
384 .IX Header "Soft Hypen Testing"
385 sig\%action
386 manu\%script
387 Jark\%ko Hie\%ta\%nie\%mi
388 .PP
389 And again:
390 .PP
391 sig\%action
392 manu\%script
393 Jark\%ko Hie\%ta\%nie\%mi
394 .PP
395 And one more time:
396 .PP
397 sig\%action
398 manu\%script
399 Jark\%ko Hie\%ta\%nie\%mi
400 ###
401
402 ###
403 =head1 XE<lt>E<gt> Whitespace
404
405 Blorpy L<B<prok>|blap> X<bivav> wugga chachacha.
406 ###
407 .SH "X<> Whitespace"
408 .IX Header "X<> Whitespace"
409 Blorpy \fBprok\fR  wugga chachacha.
410 .IX Xref "bivav"
411 ###
412
413 ###
414 =head1 Hyphen in SE<lt>E<gt>
415
416 Don't S<transform even-this hyphen>.  This "one's-fine!", as well.  However,
417 $-0.13 should have a real hyphen.
418 ###
419 .SH "Hyphen in S<>"
420 .IX Header "Hyphen in S<>"
421 Don't transform\ even-this\ hyphen.  This \*(L"one's-fine!\*(R", as well.  However,
422 $\-0.13 should have a real hyphen.
423 ###