3 # man.t -- Additional specialized tests for Pod::Man.
5 # Copyright 2002, 2003, 2004, 2006, 2007, 2008
6 # Russ Allbery <rra@stanford.edu>
8 # This program is free software; you may redistribute it and/or modify it
9 # under the same terms as Perl itself.
13 if ($ENV{PERL_CORE}) {
16 unshift (@INC, '../blib/lib');
18 unshift (@INC, '../blib/lib');
24 print "not ok 1\n" unless $loaded;
32 # Test whether we can use binmode to set encoding.
33 my $have_encoding = (eval { require PerlIO::encoding; 1 } and not $@);
35 my $parser = Pod::Man->new or die "Cannot create parser\n";
38 next until $_ eq "###\n";
39 open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n";
41 # We have a test in ISO 8859-1 encoding. Make sure that nothing strange
42 # happens if Perl thinks the world is Unicode. Wrap this in eval so that
43 # older versions of Perl don't croak.
44 eval { binmode (\*TMP, ':encoding(iso-8859-1)') if $have_encoding };
47 last if $_ eq "###\n";
51 open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n";
52 $parser->parse_from_file ('tmp.pod', \*OUT);
54 open (OUT, 'out.tmp') or die "Cannot open out.tmp: $!\n";
55 while (<OUT>) { last if /^\.nh/ }
62 unlink ('tmp.pod', 'out.tmp');
65 last if $_ eq "###\n";
68 if ($output eq $expected) {
72 print "Expected\n========\n$expected\nOutput\n======\n$output\n";
77 # Below the marker are bits of POD and corresponding expected nroff output.
78 # This is used to test specific features or problems with Pod::Man. The input
79 # and output are separated by lines containing only ###.
86 gcc - GNU project C and C++ compiler
90 Other mentions of C++.
93 gcc \- GNU project C and C++ compiler
96 Other mentions of \*(C+.
102 This C<.> should be quoted.
106 This \f(CW\*(C`.\*(C'\fR should be quoted.
120 =item * Also a bullet.
157 Beyoncé! Beyoncé! Beyoncé!!
163 Older versions didn't convert Beyoncé in verbatim.
167 Beyonce\*'! Beyonce\*'! Beyonce\*'!!
170 \& Beyonce\*'! Beyonce\*'!
171 \& Beyonce\*'! Beyonce\*'!
172 \& Beyonce\*'! Beyonce\*'!
175 Older versions didn't convert Beyonce\*' in verbatim.
181 =item 1. Not a number
183 =item 2. Spaced right
195 .IP "1. Not a number" 4
196 .IX Item "1. Not a number"
198 .IP "2. Spaced right" 4
199 .IX Item "2. Spaced right"
200 .IP "1 Not a number" 2
201 .IX Item "1 Not a number"
202 .IP "2 Spaced right" 2
203 .IX Item "2 Spaced right"
226 The quotes should be converted in the above to paired quotes.
230 \&\*(L"=over ... =back\*(R"
234 The quotes should be converted in the above to paired quotes.
240 It cost me E<165>12345! That should be an X.
244 It cost me X12345! That should be an X.
250 Open E<agrave> la shell. Previous versions mapped it wrong.
254 Open a\*` la shell. Previous versions mapped it wrong.
275 .IX Item "First level"
288 =item 1. Check fonts in @CARP_NOT test.
292 .ie n .IP "1. Check fonts in @CARP_NOT test." 4
293 .el .IP "1. Check fonts in \f(CW@CARP_NOT\fR test." 4
294 .IX Item "1. Check fonts in @CARP_NOT test."
300 There should not be double quotes: L<C<< (?>pattern) >>>.
303 .IX Header "LINK QUOTING"
304 There should not be double quotes: \f(CW\*(C`(?>pattern)\*(C'\fR.
308 =head1 SE<lt>E<gt> MAGIC
310 Magic should be applied S<RISC OS> to that.
313 .IX Header "S<> MAGIC"
314 Magic should be applied \s-1RISC\s0\ \s-1OS\s0 to that.
320 These should be identical.
322 Bippity boppity boo "The
325 Bippity boppity boo "The
329 .IX Header "MAGIC MONEY"
330 These should be identical.
332 Bippity boppity boo \*(L"The
333 price is \f(CW$100\fR.\*(R"
335 Bippity boppity boo \*(L"The
336 price is \f(CW$100\fR.\*(R"
342 "Stuff" (no guesswork)
346 Oboy, is this C++ "fun" yet! (guesswork)
349 "Stuff" (no guesswork)
351 .IX Subsection "THINGS"
352 Oboy, is this \*(C+ \*(L"fun\*(R" yet! (guesswork)
356 =head1 Newline C Quote Weirdness
361 .SH "Newline C Quote Weirdness"
362 .IX Header "Newline C Quote Weirdness"
364 \&\*(Aq\*(Aq\fR. Yes.
368 =head1 Soft Hypen Testing
372 JarkE<shy>ko HieE<shy>taE<shy>nieE<shy>mi
378 JarkE<173>ko HieE<173>taE<173>nieE<173>mi
384 JarkE<0x00AD>ko HieE<0x00AD>taE<0x00AD>nieE<0x00AD>mi
386 .SH "Soft Hypen Testing"
387 .IX Header "Soft Hypen Testing"
390 Jark\%ko Hie\%ta\%nie\%mi
396 Jark\%ko Hie\%ta\%nie\%mi
402 Jark\%ko Hie\%ta\%nie\%mi
406 =head1 XE<lt>E<gt> Whitespace
408 Blorpy L<B<prok>|blap> X<bivav> wugga chachacha.
411 .IX Header "X<> Whitespace"
412 Blorpy \fBprok\fR wugga chachacha.
417 =head1 Hyphen in SE<lt>E<gt>
419 Don't S<transform even-this hyphen>. This "one's-fine!", as well. However,
420 $-0.13 should have a real hyphen.
423 .IX Header "Hyphen in S<>"
424 Don't transform\ even-this\ hyphen. This \*(L"one's-fine!\*(R", as well. However,
425 $\-0.13 should have a real hyphen.
429 =head1 Quote escaping
431 Don't escape `this' but do escape C<`this'> (and don't surround it in quotes).
434 .IX Header "Quote escaping"
435 Don't escape `this' but do escape \f(CW\`this\*(Aq\fR (and don't surround it in quotes).
448 =head1 C<one> and C<two>
450 .ie n .SH """one"" and ""two"""
451 .el .SH "\f(CWone\fP and \f(CWtwo\fP"
452 .IX Header "one and two"