Re: [PATCH] Make the 'sort' pragma lexically scoped
[p5sagit/p5-mst-13.2.git] / lib / Pod / t / man.t
CommitLineData
2da3dd12 1#!/usr/bin/perl -w
b7ae008f 2# $Id: man.t,v 1.5 2004/02/15 06:42:49 eagle Exp $
2da3dd12 3#
4# man.t -- Additional specialized tests for Pod::Man.
5#
b7ae008f 6# Copyright 2002, 2003, 2004 by 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';
15 } else {
16 unshift (@INC, '../blib/lib');
17 }
18 unshift (@INC, '../blib/lib');
19 $| = 1;
b7ae008f 20 print "1..21\n";
2da3dd12 21}
22
23END {
24 print "not ok 1\n" unless $loaded;
25}
26
27use Pod::Man;
28
29$loaded = 1;
30print "ok 1\n";
31
81369493 32SKIP: {
33 if (defined $ENV{PERL_UNICODE}) {
0740f80f 34 print "not ok 2 # TODO Unicode not yet supported\n"
81369493 35 } else {
36 my $pod = <<EOP;
37=head1 ACCENTS
38
39Beyoncé! Beyoncé! Beyoncé!!
40
41 Beyoncé! Beyoncé!
42 Beyoncé! Beyoncé!
43 Beyoncé! Beyoncé!
44
45Older versions didn't convert Beyoncé in verbatim.
46EOP
47
48 my $expected = <<"EOM";
49.SH "ACCENTS"
50.IX Header "ACCENTS"
51Beyonce\\*'! Beyonce\\*'! Beyonce\\*'!!
52.PP
53.Vb 3
54\\& Beyonce\\*'! Beyonce\\*'!
55\\& Beyonce\\*'! Beyonce\\*'!
56\\& Beyonce\\*'! Beyonce\\*'!
57.Ve
58.PP
59Older versions didn't convert Beyonce\\*' in verbatim.
60EOM
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
84my $n = 3;
2da3dd12 85while (<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');
b7ae008f 95 undef $parser;
96 open (OUT, 'out.tmp') or die "Cannot open out.tmp: $!\n";
97 while (<OUT>) { last if /^\.TH/ }
2da3dd12 98 my $output;
99 {
100 local $/;
b7ae008f 101 $output = <OUT>;
2da3dd12 102 }
b7ae008f 103 close OUT;
2da3dd12 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
128gcc - GNU project C and C++ compiler
129
130=head1 C++ NOTES
131
132Other mentions of C++.
133###
134.SH "NAME"
135gcc \- GNU project C and C++ compiler
136.SH "\*(C+ NOTES"
137.IX Header " NOTES"
138Other mentions of \*(C+.
139###
f011ec7d 140
141###
142=head1 PERIODS
143
144This C<.> should be quoted.
145###
146.SH "PERIODS"
147.IX Header "PERIODS"
148This \f(CW\*(C`.\*(C'\fR should be quoted.
149###
4213be12 150
151###
152=over 4
153
154=item *
155
156A bullet.
157
158=item *
159
160Another bullet.
161
b7ae008f 162=item * Also a bullet.
4213be12 163
164=back
165###
166.IP "\(bu" 4
167A bullet.
168.IP "\(bu" 4
169Another bullet.
b7ae008f 170.IP "\(bu" 4
171Also a bullet.
4213be12 172###
173
174###
175=over 4
176
177=item foo
178
179Not a bullet.
180
181=item *
182
183Also not a bullet.
184
185=back
186###
187.IP "foo" 4
188.IX Item "foo"
189Not a bullet.
190.IP "*" 4
191Also not a bullet.
192###
b7ae008f 193
194###
b7ae008f 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
227Not bullet.
228
229=back
230###
231.IP "*" 4
232Not bullet.
233###
234
235###
236=head1 SEQS
237
238"=over ... Z<>=back"
239
240"SE<lt>...E<gt>"
241
242The 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
250The quotes should be converted in the above to paired quotes.
251###
252
253###
254=head1 YEN
255
256It cost me E<165>12345! That should be an X.
257###
258.SH "YEN"
259.IX Header "YEN"
260It cost me X12345! That should be an X.
261###
262
263###
264=head1 agrave
265
266Open E<agrave> la shell. Previous versions mapped it wrong.
267###
268.SH "agrave"
269.IX Header "agrave"
270Open a\*` la shell. Previous versions mapped it wrong.
271###
272
273###
274=over
275
276=item First level
277
278Blah blah blah....
279
280=over
281
282=item *
283
284Should be a bullet.
285
286=back
287
288=back
289###
290.IP "First level" 4
291.IX Item "First level"
292Blah blah blah....
293.RS 4
294.IP "\(bu" 4
295Should 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
316There should not be double quotes: L<C<< (?>pattern) >>>.
317###
318.SH "LINK QUOTING"
319.IX Header "LINK QUOTING"
320There should not be double quotes: \f(CW\*(C`(?>pattern)\*(C'\fR.
321###
322
323###
324=head1 SE<lt>E<gt> MAGIC
325
326Magic should be applied S<RISC OS> to that.
327###
328.SH "S<> MAGIC"
329.IX Header "S<> MAGIC"
330Magic should be applied \s-1RISC\s0\ \s-1OS\s0 to that.
331###
332
333###
334=head1 MAGIC MONEY
335
336These should be identical.
337
338Bippity boppity boo "The
339price is $Z<>100."
340
341Bippity boppity boo "The
342price is $100."
343###
344.SH "MAGIC MONEY"
345.IX Header "MAGIC MONEY"
346These should be identical.
347.PP
348Bippity boppity boo \*(L"The
349price is \f(CW$100\fR.\*(R"
350.PP
351Bippity boppity boo \*(L"The
352price is \f(CW$100\fR.\*(R"
353###
354
355###
356=head1 NAME
357
358"Stuff" (no guesswork)
359
360=head2 THINGS
361
362Oboy, is this C++ "fun" yet! (guesswork)
363###
364.SH "NAME"
365"Stuff" (no guesswork)
366.Sh "\s-1THINGS\s0"
367.IX Subsection "THINGS"
368Oboy, is this \*(C+ \*(L"fun\*(R" yet! (guesswork)
369###
370
371###
372=head1 Newline C Quote Weirdness
373
374Blorp C<'
375''>. Yes.
376###
377.SH "Newline C Quote Weirdness"
378.IX Header "Newline C Quote Weirdness"
379Blorp \f(CW'
380\&''\fR. Yes.
381###
382
383###
384=head1 Soft Hypen Testing
385
386sigE<shy>action
387manuE<shy>script
388JarkE<shy>ko HieE<shy>taE<shy>nieE<shy>mi
389
390And again:
391
392sigE<173>action
393manuE<173>script
394JarkE<173>ko HieE<173>taE<173>nieE<173>mi
395
396And one more time:
397
398sigE<0x00AD>action
399manuE<0x00AD>script
400JarkE<0x00AD>ko HieE<0x00AD>taE<0x00AD>nieE<0x00AD>mi
401###
402.SH "Soft Hypen Testing"
403.IX Header "Soft Hypen Testing"
404sig\%action
405manu\%script
406Jark\%ko Hie\%ta\%nie\%mi
407.PP
408And again:
409.PP
410sig\%action
411manu\%script
412Jark\%ko Hie\%ta\%nie\%mi
413.PP
414And one more time:
415.PP
416sig\%action
417manu\%script
418Jark\%ko Hie\%ta\%nie\%mi
419###
420
421###
422=head1 XE<lt>E<gt> Whitespace
423
424Blorpy L<B<prok>|blap> X<bivav> wugga chachacha.
425###
426.SH "X<> Whitespace"
427.IX Header "X<> Whitespace"
428Blorpy \fBprok\fR wugga chachacha.
429.IX Xref "bivav"
430###
431
432###
433=head1 Hyphen in SE<lt>E<gt>
434
435Don't S<transform even-this hyphen>.
436###
437.SH "Hyphen in S<>"
438.IX Header "Hyphen in S<>"
439Don't transform\ even-this\ hyphen.
440###