3 # man-options.t -- Additional tests for Pod::Man options.
5 # Copyright 2002, 2004, 2006, 2008 Russ Allbery <rra@stanford.edu>
7 # This program is free software; you may redistribute it and/or modify it
8 # under the same terms as Perl itself.
12 if ($ENV{PERL_CORE}) {
15 unshift (@INC, '../blib/lib');
17 unshift (@INC, '../blib/lib');
23 print "not ok 1\n" unless $loaded;
28 # Redirect stderr to a file.
30 open (OLDERR, '>&STDERR') or die "Can't dup STDERR: $!\n";
31 open (STDERR, '> out.err') or die "Can't redirect STDERR: $!\n";
37 open (STDERR, '>&OLDERR') or die "Can't dup STDERR: $!\n";
45 eval { binmode (\*DATA, ':encoding(utf-8)') };
48 next until $_ eq "###\n";
50 last if $_ eq "###\n";
51 my ($option, $value) = split;
52 $options{$option} = $value;
54 open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n";
55 eval { binmode (\*TMP, ':encoding(utf-8)') };
56 print TMP "=encoding utf-8\n\n";
58 last if $_ eq "###\n";
62 my $parser = Pod::Man->new (%options) or die "Cannot create parser\n";
63 open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n";
64 eval { binmode (\*OUT, ':encoding(utf-8)') };
66 $parser->parse_from_file ('tmp.pod', \*OUT);
70 open (TMP, 'out.tmp') or die "Cannot open out.tmp: $!\n";
71 eval { binmode (\*TMP, ':encoding(utf-8)') };
73 $accents = 1 if /Accent mark definitions/;
82 unlink ('tmp.pod', 'out.tmp');
83 if (($options{utf8} && !$accents) || (!$options{utf8} && $accents)) {
87 print ($accents ? "Saw accents\n" : "Saw no accents\n");
88 print ($options{utf8} ? "Wanted no accents\n" : "Wanted accents\n");
93 last if $_ eq "###\n";
96 if ($output eq $expected) {
100 print "Expected\n========\n$expected\nOutput\n======\n$output\n";
103 open (ERR, 'out.err') or die "Cannot open out.err: $!\n";
113 last if $_ eq "###\n";
116 if ($errors eq $expected) {
120 print "Expected errors:\n ${expected}Errors:\n $errors";
125 # Below the marker are bits of POD and corresponding expected text output.
126 # This is used to test specific features or problems with Pod::Man. The
127 # input and output are separated by lines containing only ###.
136 Beyoncé! Beyoncé! Beyoncé!!
142 Older versions did not convert Beyoncé in verbatim.
146 Beyoncé! Beyoncé! Beyoncé!!
154 Older versions did not convert Beyoncé in verbatim.
161 =head1 SE<lt>E<gt> output with UTF-8
163 This is S<non-breaking output>.
165 .SH "S<> output with UTF\-8"
166 .IX Header "S<> output with UTF-8"
167 This is non-breaking output.
179 C<foo B<bar I<baz>> I<bay>>
182 .IX Header "FIXED FONTS"
183 \&\f(CR\*(C`foo \f(CYbar \f(CXbaz\f(CY\f(CR \f(CWbay\f(CR\*(C'\fR
203 .IX Header "POD ERRORS"
204 Hey! \fBThe above document had some coding errors, which are explained below:\fR
205 .IP "Around line 9:" 4
206 .IX Item "Around line 9:"
207 You forgot a '=back' before '=head1'
228 tmp.pod around line 9: You forgot a '=back' before '=head1'