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