#!/usr/bin/perl -w
-# $Id: man.t,v 1.5 2004/02/15 06:42:49 eagle Exp $
#
# man.t -- Additional specialized tests for Pod::Man.
#
-# Copyright 2002, 2003, 2004 by Russ Allbery <rra@stanford.edu>
+# Copyright 2002, 2003, 2004, 2006, 2007, 2008
+# Russ Allbery <rra@stanford.edu>
#
# This program is free software; you may redistribute it and/or modify it
# under the same terms as Perl itself.
}
unshift (@INC, '../blib/lib');
$| = 1;
- print "1..21\n";
+ print "1..25\n";
}
END {
$loaded = 1;
print "ok 1\n";
-SKIP: {
- if (defined $ENV{PERL_UNICODE}) {
- print "not ok 2 # TODO Unicode not yet supported\n"
- } else {
- my $pod = <<EOP;
-=head1 ACCENTS
-
-Beyoncé! Beyoncé! Beyoncé!!
-
- Beyoncé! Beyoncé!
- Beyoncé! Beyoncé!
- Beyoncé! Beyoncé!
-
-Older versions didn't convert Beyoncé in verbatim.
-EOP
-
- my $expected = <<"EOM";
-.SH "ACCENTS"
-.IX Header "ACCENTS"
-Beyonce\\*'! Beyonce\\*'! Beyonce\\*'!!
-.PP
-.Vb 3
-\\& Beyonce\\*'! Beyonce\\*'!
-\\& Beyonce\\*'! Beyonce\\*'!
-\\& Beyonce\\*'! Beyonce\\*'!
-.Ve
-.PP
-Older versions didn't convert Beyonce\\*' in verbatim.
-EOM
- $parser = Pod::Man->new or die "Cannot create parser\n";
- open my $out_fh, ">", 'out.tmp' or die "Can't open \$out_fh: $!";
- $parser->output_fh($out_fh);
- $parser->parse_string_document($pod);
- close $out_fh;
- open my $in_fh, "<", 'out.tmp' or die "Can't open \$in_fh: $!";
- while (<$in_fh>) { last if /^\.TH/; }
- my $man;
- {
- local $/ = undef;
- $man = <$in_fh>;
- }
- close $in_fh;
- unlink 'out.tmp';
- if ($man eq $expected) {
- print "ok 2\n";
- } else {
- print "not ok 2\n";
- print "Expected\n========\n$expected\nOutput\n======\n$man\n";
- }
- }
-}
+# Test whether we can use binmode to set encoding.
+my $have_encoding = (eval { require PerlIO::encoding; 1 } and not $@);
-my $n = 3;
+my $parser = Pod::Man->new or die "Cannot create parser\n";
+my $n = 2;
while (<DATA>) {
next until $_ eq "###\n";
open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n";
+
+ # We have a test in ISO 8859-1 encoding. Make sure that nothing strange
+ # happens if Perl thinks the world is Unicode. Wrap this in eval so that
+ # older versions of Perl don't croak.
+ eval { binmode (\*TMP, ':encoding(iso-8859-1)') if $have_encoding };
+
while (<DATA>) {
last if $_ eq "###\n";
print TMP $_;
}
close TMP;
- my $parser = Pod::Man->new or die "Cannot create parser\n";
- $parser->parse_from_file ('tmp.pod', 'out.tmp');
- undef $parser;
+ open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n";
+ $parser->parse_from_file ('tmp.pod', \*OUT);
+ close OUT;
open (OUT, 'out.tmp') or die "Cannot open out.tmp: $!\n";
- while (<OUT>) { last if /^\.TH/ }
+ while (<OUT>) { last if /^\.nh/ }
my $output;
{
local $/;
###
###
+=encoding iso-8859-1
+
+=head1 ACCENTS
+
+Beyoncé! Beyoncé! Beyoncé!!
+
+ Beyoncé! Beyoncé!
+ Beyoncé! Beyoncé!
+ Beyoncé! Beyoncé!
+
+Older versions didn't convert Beyoncé in verbatim.
+###
+.SH "ACCENTS"
+.IX Header "ACCENTS"
+Beyonce\*'! Beyonce\*'! Beyonce\*'!!
+.PP
+.Vb 3
+\& Beyonce\*'! Beyonce\*'!
+\& Beyonce\*'! Beyonce\*'!
+\& Beyonce\*'! Beyonce\*'!
+.Ve
+.PP
+Older versions didn't convert Beyonce\*' in verbatim.
+###
+
+###
=over 4
=item 1. Not a number
###
.SH "NAME"
"Stuff" (no guesswork)
-.Sh "\s-1THINGS\s0"
+.SS "\s-1THINGS\s0"
.IX Subsection "THINGS"
Oboy, is this \*(C+ \*(L"fun\*(R" yet! (guesswork)
###
###
.SH "Newline C Quote Weirdness"
.IX Header "Newline C Quote Weirdness"
-Blorp \f(CW'
-\&''\fR. Yes.
+Blorp \f(CW\*(Aq
+\&\*(Aq\*(Aq\fR. Yes.
###
###
###
=head1 Hyphen in SE<lt>E<gt>
-Don't S<transform even-this hyphen>.
+Don't S<transform even-this hyphen>. This "one's-fine!", as well. However,
+$-0.13 should have a real hyphen.
###
.SH "Hyphen in S<>"
.IX Header "Hyphen in S<>"
-Don't transform\ even-this\ hyphen.
+Don't transform\ even-this\ hyphen. This \*(L"one's-fine!\*(R", as well. However,
+$\-0.13 should have a real hyphen.
+###
+
+###
+=head1 Quote escaping
+
+Don't escape `this' but do escape C<`this'> (and don't surround it in quotes).
+###
+.SH "Quote escaping"
+.IX Header "Quote escaping"
+Don't escape `this' but do escape \f(CW\`this\*(Aq\fR (and don't surround it in quotes).
+###
+
+###
+=pod
+
+E<eth>
+###
+.PP
+\&\*(d-
+###
+
+###
+=head1 C<one> and C<two>
+###
+.ie n .SH """one"" and ""two"""
+.el .SH "\f(CWone\fP and \f(CWtwo\fP"
+.IX Header "one and two"
+###
+
+###
+=pod
+
+Some text.
+
+=for man
+Some raw nroff.
+
+=for roff \fBBold text.\fP
+
+=for html
+Stuff that's hidden.
+
+=for MAN \fIItalic text.\fP
+
+=for ROFF
+.PP
+\&A paragraph.
+
+More text.
+###
+Some text.
+Some raw nroff.
+\fBBold text.\fP
+\fIItalic text.\fP
+.PP
+\&A paragraph.
+.PP
+More text.
###