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