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