Add the original source packages to maemo, source lenny
[dh-make-perl] / dev / i386 / libpod-simple-perl / libpod-simple-perl-3.07 / t / xhtml01.t
1 #!/usr/bin/perl -w
2
3 # t/xhtml01.t - check basic output from Pod::Simple::XHTML
4
5 BEGIN {
6     chdir 't' if -d 't';
7 }
8
9 use strict;
10 use lib '../lib';
11 use Test::More tests => 26;
12
13 use_ok('Pod::Simple::XHTML') or exit;
14
15 my $parser = Pod::Simple::XHTML->new ();
16 isa_ok ($parser, 'Pod::Simple::XHTML');
17
18 my $results;
19
20 my $PERLDOC = "http://search.cpan.org/perldoc?";
21
22 initialize($parser, $results);
23 $parser->parse_string_document( "=head1 Poit!" );
24 is($results, "<h1>Poit!</h1>\n\n", "head1 level output");
25
26 initialize($parser, $results);
27 $parser->parse_string_document( "=head2 I think so Brain." );
28 is($results, "<h2>I think so Brain.</h2>\n\n", "head2 level output");
29
30 initialize($parser, $results);
31 $parser->parse_string_document( "=head3 I say, Brain..." );
32 is($results, "<h3>I say, Brain...</h3>\n\n", "head3 level output");
33
34 initialize($parser, $results);
35 $parser->parse_string_document( "=head4 Zort!" );
36 is($results, "<h4>Zort!</h4>\n\n", "head4 level output");
37
38
39 initialize($parser, $results);
40 $parser->parse_string_document(<<'EOPOD');
41 =pod
42
43 Gee, Brain, what do you want to do tonight?
44 EOPOD
45
46 is($results, <<'EOHTML', "simple paragraph");
47 <p>Gee, Brain, what do you want to do tonight?</p>
48
49 EOHTML
50
51
52 initialize($parser, $results);
53 $parser->parse_string_document(<<'EOPOD');
54 =pod
55
56 B: Now, Pinky, if by any chance you are captured during this mission,
57 remember you are Gunther Heindriksen from Appenzell. You moved to
58 Grindelwald to drive the cog train to Murren. Can you repeat that?
59
60 P: Mmmm, no, Brain, don't think I can.
61 EOPOD
62
63 is($results, <<'EOHTML', "multiple paragraphs");
64 <p>B: Now, Pinky, if by any chance you are captured during this mission, remember you are Gunther Heindriksen from Appenzell. You moved to Grindelwald to drive the cog train to Murren. Can you repeat that?</p>
65
66 <p>P: Mmmm, no, Brain, don't think I can.</p>
67
68 EOHTML
69
70 initialize($parser, $results);
71 $parser->parse_string_document(<<'EOPOD');
72 =over
73
74 =item *
75
76 P: Gee, Brain, what do you want to do tonight?
77
78 =item *
79
80 B: The same thing we do every night, Pinky. Try to take over the world!
81
82 =back
83
84 EOPOD
85
86 is($results, <<'EOHTML', "simple bulleted list");
87 <ul>
88
89 <li>P: Gee, Brain, what do you want to do tonight?</li>
90
91 <li>B: The same thing we do every night, Pinky. Try to take over the world!</li>
92
93 </ul>
94
95 EOHTML
96
97
98 initialize($parser, $results);
99 $parser->parse_string_document(<<'EOPOD');
100 =over
101
102 =item 1
103
104 P: Gee, Brain, what do you want to do tonight?
105
106 =item 2
107
108 B: The same thing we do every night, Pinky. Try to take over the world!
109
110 =back
111
112 EOPOD
113
114 is($results, <<'EOHTML', "numbered list");
115 <ol>
116
117 <li>1. P: Gee, Brain, what do you want to do tonight?</li>
118
119 <li>2. B: The same thing we do every night, Pinky. Try to take over the world!</li>
120
121 </ol>
122
123 EOHTML
124
125
126 initialize($parser, $results);
127 $parser->parse_string_document(<<'EOPOD');
128 =over
129
130 =item Pinky
131
132 Gee, Brain, what do you want to do tonight?
133
134 =item Brain
135
136 The same thing we do every night, Pinky. Try to take over the world!
137
138 =back
139
140 EOPOD
141
142 is($results, <<'EOHTML', "list with text headings");
143 <ul>
144
145 <li>Pinky
146
147 <p>Gee, Brain, what do you want to do tonight?</p>
148
149 <li>Brain
150
151 <p>The same thing we do every night, Pinky. Try to take over the world!</p>
152
153 </ul>
154
155 EOHTML
156
157
158 initialize($parser, $results);
159 $parser->parse_string_document(<<'EOPOD');
160 =pod
161
162   1 + 1 = 2;
163   2 + 2 = 4;
164
165 EOPOD
166
167 is($results, <<'EOHTML', "code block");
168 <pre><code>  1 + 1 = 2;
169   2 + 2 = 4;</code></pre>
170
171 EOHTML
172
173
174 initialize($parser, $results);
175 $parser->parse_string_document(<<'EOPOD');
176 =pod
177
178 A plain paragraph with a C<functionname>.
179 EOPOD
180 is($results, <<"EOHTML", "code entity in a paragraph");
181 <p>A plain paragraph with a <code>functionname</code>.</p>
182
183 EOHTML
184
185
186 initialize($parser, $results);
187 $parser->html_header("<html>\n<body>");
188 $parser->html_footer("</body>\n</html>");
189 $parser->parse_string_document(<<'EOPOD');
190 =pod
191
192 A plain paragraph with body tags turned on.
193 EOPOD
194 is($results, <<"EOHTML", "adding html body tags");
195 <html>
196 <body>
197
198 <p>A plain paragraph with body tags turned on.</p>
199
200 </body>
201 </html>
202
203 EOHTML
204
205
206 initialize($parser, $results);
207 $parser->html_css('style.css');
208 $parser->html_header(undef);
209 $parser->html_footer(undef);
210 $parser->parse_string_document(<<'EOPOD');
211 =pod
212
213 A plain paragraph with body tags and css tags turned on.
214 EOPOD
215 like($results, qr/<link rel='stylesheet' href='style.css' type='text\/css'>/,
216 "adding html body tags and css tags");
217
218
219 initialize($parser, $results);
220 $parser->parse_string_document(<<'EOPOD');
221 =pod
222
223 A plain paragraph with S<non breaking text>.
224 EOPOD
225 is($results, <<"EOHTML", "Non breaking text in a paragraph");
226 <p>A plain paragraph with <nobr>non breaking text</nobr>.</p>
227
228 EOHTML
229
230 initialize($parser, $results);
231 $parser->parse_string_document(<<'EOPOD');
232 =pod
233
234 A plain paragraph with a L<Newlines>.
235 EOPOD
236 is($results, <<"EOHTML", "Link entity in a paragraph");
237 <p>A plain paragraph with a <a href="${PERLDOC}Newlines">Newlines</a>.</p>
238
239 EOHTML
240
241 initialize($parser, $results);
242 $parser->parse_string_document(<<'EOPOD');
243 =pod
244
245 A plain paragraph with a L<perlport/Newlines>.
246 EOPOD
247 is($results, <<"EOHTML", "Link entity in a paragraph");
248 <p>A plain paragraph with a <a href="${PERLDOC}perlport/Newlines">"Newlines" in perlport</a>.</p>
249
250 EOHTML
251
252 initialize($parser, $results);
253 $parser->parse_string_document(<<'EOPOD');
254 =pod
255
256 A plain paragraph with a L<Boo|http://link.included.here>.
257 EOPOD
258 is($results, <<"EOHTML", "A link in a paragraph");
259 <p>A plain paragraph with a <a href="http://link.included.here">Boo</a>.</p>
260
261 EOHTML
262
263 initialize($parser, $results);
264 $parser->parse_string_document(<<'EOPOD');
265 =pod
266
267 A plain paragraph with a L<http://link.included.here>.
268 EOPOD
269 is($results, <<"EOHTML", "A link in a paragraph");
270 <p>A plain paragraph with a <a href="http://link.included.here">http://link.included.here</a>.</p>
271
272 EOHTML
273
274 initialize($parser, $results);
275 $parser->parse_string_document(<<'EOPOD');
276 =pod
277
278 A plain paragraph with B<bold text>.
279 EOPOD
280 is($results, <<"EOHTML", "Bold text in a paragraph");
281 <p>A plain paragraph with <b>bold text</b>.</p>
282
283 EOHTML
284
285 initialize($parser, $results);
286 $parser->parse_string_document(<<'EOPOD');
287 =pod
288
289 A plain paragraph with I<italic text>.
290 EOPOD
291 is($results, <<"EOHTML", "Italic text in a paragraph");
292 <p>A plain paragraph with <i>italic text</i>.</p>
293
294 EOHTML
295
296 initialize($parser, $results);
297 $parser->parse_string_document(<<'EOPOD');
298 =pod
299
300 A plain paragraph with a F<filename>.
301 EOPOD
302 is($results, <<"EOHTML", "File name in a paragraph");
303 <p>A plain paragraph with a <i>filename</i>.</p>
304
305 EOHTML
306
307
308 initialize($parser, $results);
309 $parser->parse_string_document(<<'EOPOD');
310 =pod
311
312   # this header is very important & don't you forget it
313   my $text = "File is: " . <FILE>;
314 EOPOD
315 is($results, <<"EOHTML", "Verbatim text with encodable entities");
316 <pre><code>  # this header is very important &amp; don&#39;t you forget it
317   my \$text = &quot;File is: &quot; . &lt;FILE&gt;;</code></pre>
318
319 EOHTML
320
321 SKIP: for my $use_html_entities (0, 1) {
322   if ($use_html_entities and not $Pod::Simple::XHTML::HAS_HTML_ENTITIES) {
323     skip("HTML::Entities not installed", 1);
324   }
325   local $Pod::Simple::XHTML::HAS_HTML_ENTITIES = $use_html_entities;
326   initialize($parser, $results);
327   $parser->parse_string_document(<<'EOPOD');
328 =pod
329
330   # this header is very important & don't you forget it
331   B<my $file = <FILEE<gt> || 'Blank!';>
332   my $text = "File is: " . <FILE>;
333 EOPOD
334 is($results, <<"EOHTML", "Verbatim text with markup and embedded formatting");
335 <pre><code>  # this header is very important &amp; don&#39;t you forget it
336   <b>my \$file = &lt;FILE&gt; || &#39;Blank!&#39;;</b>
337   my \$text = &quot;File is: &quot; . &lt;FILE&gt;;</code></pre>
338
339 EOHTML
340 }
341
342 ######################################
343
344 sub initialize {
345         $_[0] = Pod::Simple::XHTML->new ();
346         $_[0]->html_header("");
347         $_[0]->html_footer("");
348         $_[0]->output_string( \$results ); # Send the resulting output to a string
349         $_[1] = '';
350         return;
351 }