Update to podlators 2.3.0
[p5sagit/p5-mst-13.2.git] / cpan / podlators / t / man.t
1 #!/usr/bin/perl -w
2 #
3 # man.t -- Additional specialized tests for Pod::Man.
4 #
5 # Copyright 2002, 2003, 2004, 2006, 2007, 2008, 2009
6 #     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     }
16     unshift (@INC, '../blib/lib');
17     $| = 1;
18 }
19
20 use strict;
21
22 use Test::More tests => 30;
23 BEGIN { use_ok ('Pod::Man') }
24
25 # Test whether we can use binmode to set encoding.
26 my $have_encoding = (eval { require PerlIO::encoding; 1 } and not $@);
27
28 my $parser = Pod::Man->new;
29 isa_ok ($parser, 'Pod::Man', 'Parser object');
30 my $n = 1;
31 while (<DATA>) {
32     next until $_ eq "###\n";
33     open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n";
34
35     # We have a test in ISO 8859-1 encoding.  Make sure that nothing strange
36     # happens if Perl thinks the world is Unicode.  Wrap this in eval so that
37     # older versions of Perl don't croak.
38     eval { binmode (\*TMP, ':encoding(iso-8859-1)') if $have_encoding };
39
40     while (<DATA>) {
41         last if $_ eq "###\n";
42         print TMP $_;
43     }
44     close TMP;
45     open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n";
46     $parser->parse_from_file ('tmp.pod', \*OUT);
47     close OUT;
48     open (OUT, 'out.tmp') or die "Cannot open out.tmp: $!\n";
49     while (<OUT>) { last if /^\.nh/ }
50     my $output;
51     {
52         local $/;
53         $output = <OUT>;
54     }
55     close OUT;
56     1 while unlink ('tmp.pod', 'out.tmp');
57     my $expected = '';
58     while (<DATA>) {
59         last if $_ eq "###\n";
60         $expected .= $_;
61     }
62     is ($output, $expected, "Output correct for test $n");
63     $n++;
64 }
65
66 # Below the marker are bits of POD and corresponding expected nroff output.
67 # This is used to test specific features or problems with Pod::Man.  The input
68 # and output are separated by lines containing only ###.
69
70 __DATA__
71
72 ###
73 =head1 NAME
74
75 gcc - GNU project C<C> and C++ compiler
76
77 =head1 C++ NOTES
78
79 Other mentions of C++.
80 ###
81 .SH "NAME"
82 gcc \- GNU project "C" and C++ compiler
83 .SH "\*(C+ NOTES"
84 .IX Header " NOTES"
85 Other mentions of \*(C+.
86 ###
87
88 ###
89 =head1 PERIODS
90
91 This C<.> should be quoted.
92 ###
93 .SH "PERIODS"
94 .IX Header "PERIODS"
95 This \f(CW\*(C`.\*(C'\fR should be quoted.
96 ###
97
98 ###
99 =over 4
100
101 =item *
102
103 A bullet.
104
105 =item    *
106
107 Another bullet.
108
109 =item * Also a bullet.
110
111 =back
112 ###
113 .IP "\(bu" 4
114 A bullet.
115 .IP "\(bu" 4
116 Another bullet.
117 .IP "\(bu" 4
118 Also a bullet.
119 ###
120
121 ###
122 =over 4
123
124 =item foo
125
126 Not a bullet.
127
128 =item *
129
130 Also not a bullet.
131
132 =back
133 ###
134 .IP "foo" 4
135 .IX Item "foo"
136 Not a bullet.
137 .IP "*" 4
138 Also not a bullet.
139 ###
140
141 ###
142 =encoding iso-8859-1
143
144 =head1 ACCENTS
145
146 Beyoncé!  Beyoncé!  Beyoncé!!
147
148     Beyoncé!  Beyoncé!
149       Beyoncé!  Beyoncé!
150         Beyoncé!  Beyoncé!
151
152 Older versions didn't convert Beyoncé in verbatim.
153 ###
154 .SH "ACCENTS"
155 .IX Header "ACCENTS"
156 Beyonce\*'!  Beyonce\*'!  Beyonce\*'!!
157 .PP
158 .Vb 3
159 \&    Beyonce\*'!  Beyonce\*'!
160 \&      Beyonce\*'!  Beyonce\*'!
161 \&        Beyonce\*'!  Beyonce\*'!
162 .Ve
163 .PP
164 Older versions didn't convert Beyonce\*' in verbatim.
165 ###
166
167 ###
168 =over 4
169
170 =item 1. Not a number
171
172 =item 2. Spaced right
173
174 =back
175
176 =over 2
177
178 =item 1 Not a number
179
180 =item 2 Spaced right
181
182 =back
183 ###
184 .IP "1. Not a number" 4
185 .IX Item "1. Not a number"
186 .PD 0
187 .IP "2. Spaced right" 4
188 .IX Item "2. Spaced right"
189 .IP "1 Not a number" 2
190 .IX Item "1 Not a number"
191 .IP "2 Spaced right" 2
192 .IX Item "2 Spaced right"
193 ###
194
195 ###
196 =over 4
197
198 =item Z<>*
199
200 Not bullet.
201
202 =back
203 ###
204 .IP "*" 4
205 Not bullet.
206 ###
207
208 ###
209 =head1 SEQS
210
211 "=over ... Z<>=back"
212
213 "SE<lt>...E<gt>"
214
215 The quotes should be converted in the above to paired quotes.
216 ###
217 .SH "SEQS"
218 .IX Header "SEQS"
219 \&\*(L"=over ... =back\*(R"
220 .PP
221 \&\*(L"S<...>\*(R"
222 .PP
223 The quotes should be converted in the above to paired quotes.
224 ###
225
226 ###
227 =head1 YEN
228
229 It cost me E<165>12345! That should be an X.
230 ###
231 .SH "YEN"
232 .IX Header "YEN"
233 It cost me X12345! That should be an X.
234 ###
235
236 ###
237 =head1 agrave
238
239 Open E<agrave> la shell. Previous versions mapped it wrong.
240 ###
241 .SH "agrave"
242 .IX Header "agrave"
243 Open a\*` la shell. Previous versions mapped it wrong.
244 ###
245
246 ###
247 =over
248
249 =item First level
250
251 Blah blah blah....
252
253 =over
254
255 =item *
256
257 Should be a bullet.
258
259 =back
260
261 =back
262 ###
263 .IP "First level" 4
264 .IX Item "First level"
265 Blah blah blah....
266 .RS 4
267 .IP "\(bu" 4
268 Should be a bullet.
269 .RE
270 .RS 4
271 .RE
272 ###
273
274 ###
275 =over 4
276
277 =item 1. Check fonts in @CARP_NOT test.
278
279 =back
280 ###
281 .ie n .IP "1. Check fonts in @CARP_NOT test." 4
282 .el .IP "1. Check fonts in \f(CW@CARP_NOT\fR test." 4
283 .IX Item "1. Check fonts in @CARP_NOT test."
284 ###
285
286 ###
287 =head1 LINK QUOTING
288
289 There should not be double quotes: L<C<< (?>pattern) >>>.
290 ###
291 .SH "LINK QUOTING"
292 .IX Header "LINK QUOTING"
293 There should not be double quotes: \f(CW\*(C`(?>pattern)\*(C'\fR.
294 ###
295
296 ###
297 =head1 SE<lt>E<gt> MAGIC
298
299 Magic should be applied S<RISC OS> to that.
300 ###
301 .SH "S<> MAGIC"
302 .IX Header "S<> MAGIC"
303 Magic should be applied \s-1RISC\s0\ \s-1OS\s0 to that.
304 ###
305
306 ###
307 =head1 MAGIC MONEY
308
309 These should be identical.
310
311 Bippity boppity boo "The
312 price is $Z<>100."
313
314 Bippity boppity boo "The
315 price is $100."
316 ###
317 .SH "MAGIC MONEY"
318 .IX Header "MAGIC MONEY"
319 These should be identical.
320 .PP
321 Bippity boppity boo \*(L"The
322 price is \f(CW$100\fR.\*(R"
323 .PP
324 Bippity boppity boo \*(L"The
325 price is \f(CW$100\fR.\*(R"
326 ###
327
328 ###
329 =head1 NAME
330
331 "Stuff" (no guesswork)
332
333 =head2 THINGS
334
335 Oboy, is this C++ "fun" yet! (guesswork)
336 ###
337 .SH "NAME"
338 "Stuff" (no guesswork)
339 .SS "\s-1THINGS\s0"
340 .IX Subsection "THINGS"
341 Oboy, is this \*(C+ \*(L"fun\*(R" yet! (guesswork)
342 ###
343
344 ###
345 =head1 Newline C Quote Weirdness
346
347 Blorp C<'
348 ''>. Yes.
349 ###
350 .SH "Newline C Quote Weirdness"
351 .IX Header "Newline C Quote Weirdness"
352 Blorp \f(CW\*(Aq
353 \&\*(Aq\*(Aq\fR. Yes.
354 ###
355
356 ###
357 =head1 Soft Hypen Testing
358
359 sigE<shy>action
360 manuE<shy>script
361 JarkE<shy>ko HieE<shy>taE<shy>nieE<shy>mi
362
363 And again:
364
365 sigE<173>action
366 manuE<173>script
367 JarkE<173>ko HieE<173>taE<173>nieE<173>mi
368
369 And one more time:
370
371 sigE<0x00AD>action
372 manuE<0x00AD>script
373 JarkE<0x00AD>ko HieE<0x00AD>taE<0x00AD>nieE<0x00AD>mi
374 ###
375 .SH "Soft Hypen Testing"
376 .IX Header "Soft Hypen Testing"
377 sig\%action
378 manu\%script
379 Jark\%ko Hie\%ta\%nie\%mi
380 .PP
381 And again:
382 .PP
383 sig\%action
384 manu\%script
385 Jark\%ko Hie\%ta\%nie\%mi
386 .PP
387 And one more time:
388 .PP
389 sig\%action
390 manu\%script
391 Jark\%ko Hie\%ta\%nie\%mi
392 ###
393
394 ###
395 =head1 XE<lt>E<gt> Whitespace
396
397 Blorpy L<B<prok>|blap> X<bivav> wugga chachacha.
398 ###
399 .SH "X<> Whitespace"
400 .IX Header "X<> Whitespace"
401 Blorpy \fBprok\fR  wugga chachacha.
402 .IX Xref "bivav"
403 ###
404
405 ###
406 =head1 Hyphen in SE<lt>E<gt>
407
408 Don't S<transform even-this hyphen>.  This "one's-fine!", as well.  However,
409 $-0.13 should have a real hyphen.
410 ###
411 .SH "Hyphen in S<>"
412 .IX Header "Hyphen in S<>"
413 Don't transform\ even-this\ hyphen.  This \*(L"one's-fine!\*(R", as well.  However,
414 $\-0.13 should have a real hyphen.
415 ###
416
417 ###
418 =head1 Quote escaping
419
420 Don't escape `this' but do escape C<`this'> (and don't surround it in quotes).
421 ###
422 .SH "Quote escaping"
423 .IX Header "Quote escaping"
424 Don't escape `this' but do escape \f(CW\`this\*(Aq\fR (and don't surround it in quotes).
425 ###
426
427 ###
428 =pod
429
430 E<eth>
431 ###
432 .PP
433 \&\*(d-
434 ###
435
436 ###
437 =head1 C<one> and C<two>
438 ###
439 .ie n .SH """one"" and ""two"""
440 .el .SH "\f(CWone\fP and \f(CWtwo\fP"
441 .IX Header "one and two"
442 ###
443
444 ###
445 =pod
446
447 Some text.
448
449 =for man
450 Some raw nroff.
451
452 =for roff \fBBold text.\fP
453
454 =for html
455 Stuff that's hidden.
456
457 =for MAN \fIItalic text.\fP
458
459 =for ROFF
460 .PP
461 \&A paragraph.
462
463 More text.
464 ###
465 Some text.
466 Some raw nroff.
467 \fBBold text.\fP
468 \fIItalic text.\fP
469 .PP
470 \&A paragraph.
471 .PP
472 More text.
473 ###
474
475 ###
476 =head1 NAME
477
478 test - C<test>
479 ###
480 .SH "NAME"
481 test \- "test"
482 ###
483
484 ###
485 =head1 INDEX
486
487 Index entry matching a whitespace escape.X<\n>
488 ###
489 .SH "INDEX"
490 .IX Header "INDEX"
491 Index entry matching a whitespace escape.
492 .IX Xref "\\n"
493 ###
494
495 ###
496 =head1 LINK TO URL
497
498 This is a L<link|http://www.example.com/> to a URL.
499 ###
500 .SH "LINK TO URL"
501 .IX Header "LINK TO URL"
502 This is a link <http://www.example.com/> to a \s-1URL\s0.
503 ###
504
505 ###
506 =head1 NAME
507
508 test - B<test> I<italics> F<file>
509 ###
510 .SH "NAME"
511 test \- test italics file
512 ###