3 # man.t -- Additional specialized tests for Pod::Man.
5 # Copyright 2002, 2003, 2004, 2006, 2007, 2008, 2009
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');
22 use Test::More tests => 30;
23 BEGIN { use_ok ('Pod::Man') }
25 # Test whether we can use binmode to set encoding.
26 my $have_encoding = (eval { require PerlIO::encoding; 1 } and not $@);
28 my $parser = Pod::Man->new;
29 isa_ok ($parser, 'Pod::Man', 'Parser object');
32 next until $_ eq "###\n";
33 open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n";
35 # We have a test in ISO 8859-1 encoding. Make sure that nothing strange
36 # happens if Perl thinks the world is Unicode. Wrap this in eval so that
37 # older versions of Perl don't croak.
38 eval { binmode (\*TMP, ':encoding(iso-8859-1)') if $have_encoding };
41 last if $_ eq "###\n";
45 open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n";
46 $parser->parse_from_file ('tmp.pod', \*OUT);
48 open (OUT, 'out.tmp') or die "Cannot open out.tmp: $!\n";
49 while (<OUT>) { last if /^\.nh/ }
56 1 while unlink ('tmp.pod', 'out.tmp');
59 last if $_ eq "###\n";
62 is ($output, $expected, "Output correct for test $n");
66 # Below the marker are bits of POD and corresponding expected nroff output.
67 # This is used to test specific features or problems with Pod::Man. The input
68 # and output are separated by lines containing only ###.
75 gcc - GNU project C<C> and C++ compiler
79 Other mentions of C++.
82 gcc \- GNU project "C" and C++ compiler
85 Other mentions of \*(C+.
91 This C<.> should be quoted.
95 This \f(CW\*(C`.\*(C'\fR should be quoted.
109 =item * Also a bullet.
146 Beyoncé! Beyoncé! Beyoncé!!
152 Older versions didn't convert Beyoncé in verbatim.
156 Beyonce\*'! Beyonce\*'! Beyonce\*'!!
159 \& Beyonce\*'! Beyonce\*'!
160 \& Beyonce\*'! Beyonce\*'!
161 \& Beyonce\*'! Beyonce\*'!
164 Older versions didn't convert Beyonce\*' in verbatim.
170 =item 1. Not a number
172 =item 2. Spaced right
184 .IP "1. Not a number" 4
185 .IX Item "1. Not a number"
187 .IP "2. Spaced right" 4
188 .IX Item "2. Spaced right"
189 .IP "1 Not a number" 2
190 .IX Item "1 Not a number"
191 .IP "2 Spaced right" 2
192 .IX Item "2 Spaced right"
215 The quotes should be converted in the above to paired quotes.
219 \&\*(L"=over ... =back\*(R"
223 The quotes should be converted in the above to paired quotes.
229 It cost me E<165>12345! That should be an X.
233 It cost me X12345! That should be an X.
239 Open E<agrave> la shell. Previous versions mapped it wrong.
243 Open a\*` la shell. Previous versions mapped it wrong.
264 .IX Item "First level"
277 =item 1. Check fonts in @CARP_NOT test.
281 .ie n .IP "1. Check fonts in @CARP_NOT test." 4
282 .el .IP "1. Check fonts in \f(CW@CARP_NOT\fR test." 4
283 .IX Item "1. Check fonts in @CARP_NOT test."
289 There should not be double quotes: L<C<< (?>pattern) >>>.
292 .IX Header "LINK QUOTING"
293 There should not be double quotes: \f(CW\*(C`(?>pattern)\*(C'\fR.
297 =head1 SE<lt>E<gt> MAGIC
299 Magic should be applied S<RISC OS> to that.
302 .IX Header "S<> MAGIC"
303 Magic should be applied \s-1RISC\s0\ \s-1OS\s0 to that.
309 These should be identical.
311 Bippity boppity boo "The
314 Bippity boppity boo "The
318 .IX Header "MAGIC MONEY"
319 These should be identical.
321 Bippity boppity boo \*(L"The
322 price is \f(CW$100\fR.\*(R"
324 Bippity boppity boo \*(L"The
325 price is \f(CW$100\fR.\*(R"
331 "Stuff" (no guesswork)
335 Oboy, is this C++ "fun" yet! (guesswork)
338 "Stuff" (no guesswork)
340 .IX Subsection "THINGS"
341 Oboy, is this \*(C+ \*(L"fun\*(R" yet! (guesswork)
345 =head1 Newline C Quote Weirdness
350 .SH "Newline C Quote Weirdness"
351 .IX Header "Newline C Quote Weirdness"
353 \&\*(Aq\*(Aq\fR. Yes.
357 =head1 Soft Hypen Testing
361 JarkE<shy>ko HieE<shy>taE<shy>nieE<shy>mi
367 JarkE<173>ko HieE<173>taE<173>nieE<173>mi
373 JarkE<0x00AD>ko HieE<0x00AD>taE<0x00AD>nieE<0x00AD>mi
375 .SH "Soft Hypen Testing"
376 .IX Header "Soft Hypen Testing"
379 Jark\%ko Hie\%ta\%nie\%mi
385 Jark\%ko Hie\%ta\%nie\%mi
391 Jark\%ko Hie\%ta\%nie\%mi
395 =head1 XE<lt>E<gt> Whitespace
397 Blorpy L<B<prok>|blap> X<bivav> wugga chachacha.
400 .IX Header "X<> Whitespace"
401 Blorpy \fBprok\fR wugga chachacha.
406 =head1 Hyphen in SE<lt>E<gt>
408 Don't S<transform even-this hyphen>. This "one's-fine!", as well. However,
409 $-0.13 should have a real hyphen.
412 .IX Header "Hyphen in S<>"
413 Don't transform\ even-this\ hyphen. This \*(L"one's-fine!\*(R", as well. However,
414 $\-0.13 should have a real hyphen.
418 =head1 Quote escaping
420 Don't escape `this' but do escape C<`this'> (and don't surround it in quotes).
423 .IX Header "Quote escaping"
424 Don't escape `this' but do escape \f(CW\`this\*(Aq\fR (and don't surround it in quotes).
437 =head1 C<one> and C<two>
439 .ie n .SH """one"" and ""two"""
440 .el .SH "\f(CWone\fP and \f(CWtwo\fP"
441 .IX Header "one and two"
452 =for roff \fBBold text.\fP
457 =for MAN \fIItalic text.\fP
487 Index entry matching a whitespace escape.X<\n>
491 Index entry matching a whitespace escape.
498 This is a L<link|http://www.example.com/> to a URL.
501 .IX Header "LINK TO URL"
502 This is a link <http://www.example.com/> to a \s-1URL\s0.
508 test - B<test> I<italics> F<file>
511 test \- test italics file