Commit | Line | Data |
11f72409 |
1 | #!/usr/bin/perl -w |
b7ae008f |
2 | # $Id: text-options.t,v 1.4 2004/12/31 21:29:34 eagle Exp $ |
11f72409 |
3 | # |
4 | # text-options.t -- Additional tests for Pod::Text options. |
5 | # |
b7ae008f |
6 | # Copyright 2002, 2004 by Russ Allbery <rra@stanford.edu> |
11f72409 |
7 | # |
8 | # This program is free software; you may redistribute it and/or modify it |
9 | # under the same terms as Perl itself. |
10 | |
11 | BEGIN { |
12 | chdir 't' if -d 't'; |
13 | if ($ENV{PERL_CORE}) { |
14 | @INC = '../lib'; |
15 | } else { |
16 | unshift (@INC, '../blib/lib'); |
17 | } |
18 | unshift (@INC, '../blib/lib'); |
19 | $| = 1; |
b7ae008f |
20 | print "1..5\n"; |
11f72409 |
21 | } |
22 | |
23 | END { |
24 | print "not ok 1\n" unless $loaded; |
25 | } |
26 | |
27 | use Pod::Text; |
28 | |
29 | $loaded = 1; |
30 | print "ok 1\n"; |
31 | |
32 | my $n = 2; |
33 | while (<DATA>) { |
34 | my %options; |
35 | next until $_ eq "###\n"; |
36 | while (<DATA>) { |
37 | last if $_ eq "###\n"; |
38 | my ($option, $value) = split; |
39 | $options{$option} = $value; |
40 | } |
41 | open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n"; |
42 | while (<DATA>) { |
43 | last if $_ eq "###\n"; |
44 | print TMP $_; |
45 | } |
46 | close TMP; |
47 | my $parser = Pod::Text->new (%options) or die "Cannot create parser\n"; |
48 | $parser->parse_from_file ('tmp.pod', 'out.tmp'); |
b7ae008f |
49 | undef $parser; |
11f72409 |
50 | open (TMP, 'out.tmp') or die "Cannot open out.tmp: $!\n"; |
51 | my $output; |
52 | { |
53 | local $/; |
54 | $output = <TMP>; |
55 | } |
56 | close TMP; |
57 | unlink ('tmp.pod', 'out.tmp'); |
58 | my $expected = ''; |
59 | while (<DATA>) { |
60 | last if $_ eq "###\n"; |
61 | $expected .= $_; |
62 | } |
63 | if ($output eq $expected) { |
64 | print "ok $n\n"; |
65 | } else { |
66 | print "not ok $n\n"; |
67 | print "Expected\n========\n$expected\nOutput\n======\n$output\n"; |
68 | } |
69 | $n++; |
70 | } |
71 | |
72 | # Below the marker are bits of POD and corresponding expected text output. |
73 | # This is used to test specific features or problems with Pod::Text. The |
74 | # input and output are separated by lines containing only ###. |
75 | |
76 | __DATA__ |
77 | |
78 | ### |
79 | alt 1 |
80 | ### |
81 | =head1 SAMPLE |
82 | |
83 | =over 4 |
84 | |
85 | =item F |
86 | |
87 | Paragraph. |
88 | |
89 | =item Bar |
90 | |
91 | =item B |
92 | |
93 | Paragraph. |
94 | |
95 | =item Longer |
96 | |
97 | Paragraph. |
98 | |
99 | =back |
100 | |
101 | ### |
102 | |
103 | ==== SAMPLE ==== |
104 | |
105 | : F Paragraph. |
106 | |
107 | : Bar |
108 | : B Paragraph. |
109 | |
110 | : Longer |
111 | Paragraph. |
112 | |
113 | ### |
114 | |
115 | ### |
116 | margin 4 |
117 | ### |
118 | =head1 SAMPLE |
119 | |
120 | This is some body text that is long enough to be a paragraph that wraps, |
121 | thereby testing margins with wrapped paragraphs. |
122 | |
123 | This is some verbatim text. |
124 | |
125 | =over 6 |
126 | |
127 | =item Test |
128 | |
129 | This is a test of an indented paragraph. |
130 | |
131 | This is another indented paragraph. |
132 | |
133 | =back |
134 | ### |
135 | SAMPLE |
136 | This is some body text that is long enough to be a paragraph that |
137 | wraps, thereby testing margins with wrapped paragraphs. |
138 | |
139 | This is some verbatim text. |
140 | |
141 | Test This is a test of an indented paragraph. |
142 | |
143 | This is another indented paragraph. |
144 | |
145 | ### |
b7ae008f |
146 | |
147 | ### |
148 | code 1 |
149 | ### |
150 | This is some random text. |
151 | This is more random text. |
152 | |
153 | This is some random text. |
154 | This is more random text. |
155 | |
156 | =head1 SAMPLE |
157 | |
158 | This is POD. |
159 | |
160 | =cut |
161 | |
162 | This is more random text. |
163 | ### |
164 | This is some random text. |
165 | This is more random text. |
166 | |
167 | This is some random text. |
168 | This is more random text. |
169 | |
170 | SAMPLE |
171 | This is POD. |
172 | |
173 | |
174 | This is more random text. |
175 | ### |
176 | |
177 | ### |
178 | sentence 1 |
179 | ### |
180 | =head1 EXAMPLE |
181 | |
182 | Whitespace around C<< this. >> must be ignored per perlpodspec. >> |
183 | needs to eat all of the space in front of it. |
184 | |
185 | =cut |
186 | ### |
187 | EXAMPLE |
188 | Whitespace around "this." must be ignored per perlpodspec. >> needs to |
189 | eat all of the space in front of it. |
190 | |
191 | ### |