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