Upgrade to podlators 2.1.2
[p5sagit/p5-mst-13.2.git] / lib / Pod / t / man-options.t
1 #!/usr/bin/perl -w
2 #
3 # man-options.t -- Additional tests for Pod::Man options.
4 #
5 # Copyright 2002, 2004, 2006, 2008 Russ Allbery <rra@stanford.edu>
6 #
7 # This program is free software; you may redistribute it and/or modify it
8 # under the same terms as Perl itself.
9
10 BEGIN {
11     chdir 't' if -d 't';
12     if ($ENV{PERL_CORE}) {
13         @INC = '../lib';
14     } else {
15         unshift (@INC, '../blib/lib');
16     }
17     unshift (@INC, '../blib/lib');
18     $| = 1;
19     print "1..7\n";
20 }
21
22 END {
23     print "not ok 1\n" unless $loaded;
24 }
25
26 use Pod::Man;
27
28 $loaded = 1;
29 print "ok 1\n";
30
31 my $n = 2;
32 while (<DATA>) {
33     my %options;
34     next until $_ eq "###\n";
35     while (<DATA>) {
36         last if $_ eq "###\n";
37         my ($option, $value) = split;
38         $options{$option} = $value;
39     }
40     open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n";
41     while (<DATA>) {
42         last if $_ eq "###\n";
43         print TMP $_;
44     }
45     close TMP;
46     my $parser = Pod::Man->new (%options) or die "Cannot create parser\n";
47     open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n";
48     $parser->parse_from_file ('tmp.pod', \*OUT);
49     close OUT;
50     my $accents = 0;
51     open (TMP, 'out.tmp') or die "Cannot open out.tmp: $!\n";
52     while (<TMP>) {
53         $accents = 1 if /Accent mark definitions/;
54         last if /^\.nh/;
55     }
56     my $output;
57     {
58         local $/;
59         $output = <TMP>;
60     }
61     close TMP;
62     unlink ('tmp.pod', 'out.tmp');
63     if (($options{utf8} && !$accents) || (!$options{utf8} && $accents)) {
64         print "ok $n\n";
65     } else {
66         print "not ok $n\n";
67         print ($accents ? "Saw accents\n" : "Saw no accents\n");
68         print ($options{utf8} ? "Wanted no accents\n" : "Wanted accents\n");
69     }
70     $n++;
71     my $expected = '';
72     while (<DATA>) {
73         last if $_ eq "###\n";
74         $expected .= $_;
75     }
76     if ($output eq $expected) {
77         print "ok $n\n";
78     } else {
79         print "not ok $n\n";
80         print "Expected\n========\n$expected\nOutput\n======\n$output\n";
81     }
82     $n++;
83 }
84
85 # Below the marker are bits of POD and corresponding expected text output.
86 # This is used to test specific features or problems with Pod::Man.  The
87 # input and output are separated by lines containing only ###.
88
89 __DATA__
90
91 ###
92 utf8 1
93 ###
94 =head1 BEYONCÉ
95
96 Beyoncé!  Beyoncé!  Beyoncé!!
97
98     Beyoncé!  Beyoncé!
99       Beyoncé!  Beyoncé!
100         Beyoncé!  Beyoncé!
101
102 Older versions did not convert Beyoncé in verbatim.
103 ###
104 .SH "BEYONCÉ"
105 .IX Header "BEYONCÉ"
106 Beyoncé!  Beyoncé!  Beyoncé!!
107 .PP
108 .Vb 3
109 \&    Beyoncé!  Beyoncé!
110 \&      Beyoncé!  Beyoncé!
111 \&        Beyoncé!  Beyoncé!
112 .Ve
113 .PP
114 Older versions did not convert Beyoncé in verbatim.
115 ###
116
117 ###
118 utf8 1
119 ###
120 =head1 SE<lt>E<gt> output with UTF-8
121
122 This is S<non-breaking output>.
123 ###
124 .SH "S<> output with UTF\-8"
125 .IX Header "S<> output with UTF-8"
126 This is non\-breaking output.
127 ###
128
129 ###
130 fixed CR
131 fixedbold CY
132 fixeditalic CW
133 fixedbolditalic CX
134 ###
135 =head1 FIXED FONTS
136
137 C<foo B<bar I<baz>> I<bay>>
138 ###
139 .SH "FIXED FONTS"
140 .IX Header "FIXED FONTS"
141 \&\f(CR\*(C`foo \f(CYbar \f(CXbaz\f(CY\f(CR \f(CWbay\f(CR\*(C'\fR
142 ###