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