/[socialtext-import]/Pod-Simple-Wiki/t/03_lists_twiki.t
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /Pod-Simple-Wiki/t/03_lists_twiki.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3 - (show annotations)
Tue Nov 28 14:15:41 2006 UTC (17 years, 5 months ago) by dpavlin
File MIME type: application/x-troff
File size: 7062 byte(s)
import upstream Pod-Simple-Wiki-0.05.tar.gz
1 #!/usr/bin/perl -w
2
3 ###############################################################################
4 #
5 # A test for Pod::Simple::Wiki.
6 #
7 # Tests for =over ... =back regions.
8 #
9 # reverse('©'), March 2005, John McNamara, jmcnamara@cpan.org
10 #
11
12
13 use strict;
14
15 use Pod::Simple::Wiki;
16 use Test::More tests => 12;
17
18 my $style = 'twiki';
19
20 # Output the tests for visual testing in the wiki.
21 # END{output_tests()};
22
23 my @tests;
24
25 #
26 # Extract tests embedded in _DATA_ section.
27 #
28 my $test_no = 1;
29 my $pod;
30 my $test = '';
31 my $todo = '';;
32 my $name;
33
34 while (<DATA>) {
35 if (/^#/) {
36 $name = $1 if /NAME: (.*)/;
37 $todo = $1 if /TODO: (.*)/;
38
39 if ($test) {
40 if ($test_no % 2) {
41 $pod = $test;
42 }
43 else {
44 push @tests, [$pod, $test, $name, $todo];
45 $name = '';
46 $todo = '';
47 }
48
49 $test = '';
50 $test_no++;
51 }
52 next;
53 }
54 s/\r//; # Remove any \r chars that slip in.
55 s/\\t/\t/g; # Sub back in any escaped tabs.
56 s/\\#/#/g; # Sub back in any escaped comments.
57 $test .= $_;
58 }
59
60
61 ###############################################################################
62 #
63 # Run the tests.
64 #
65 for my $test_ref (@tests) {
66
67 my $parser = Pod::Simple::Wiki->new($style);
68 my $pod = $test_ref->[0];
69 my $target = $test_ref->[1];
70 my $name = $test_ref->[2];
71 my $todo = $test_ref->[3];
72 my $wiki;
73
74 $parser->output_string(\$wiki);
75 $parser->parse_string_document($pod);
76
77 local $TODO = $todo;
78 is($wiki, $target, " \t" . $name);
79 }
80
81
82 ###############################################################################
83 #
84 # Output the tests for visual testing in the wiki.
85 #
86 sub output_tests {
87
88 my $test = 1;
89
90 print "\n----\n\n";
91
92 for my $test_ref (@tests) {
93
94 my $parser = Pod::Simple::Wiki->new($style);
95 my $pod = $test_ref->[0];
96 my $name = $test_ref->[2];
97
98 $name =~ s[<][&lt;]g;
99 $name =~ s[>][&gt;]g;
100
101 print "Test ", $test++, ":\t", $name, "\n";
102 $parser->parse_string_document($pod);
103 print "\n----\n\n";
104 }
105 }
106
107 __DATA__
108 ################################################################################
109 #
110 # Test data.
111 #
112 ################################################################################
113 #
114 # NAME: Test for single unordered (bullet) item.
115 #
116 =pod
117
118 =over
119
120 =item *
121
122 Bullet item
123
124 =back
125
126 =cut
127 #
128 #
129 # Expected output.
130 #
131 #
132 * Bullet item
133
134 ################################################################################
135 #
136 # NAME: Test for unordered (bullet) list, <ul>.
137 #
138 =pod
139
140 =over
141
142 =item *
143
144 Bullet item 1.0
145
146 =item *
147
148 Bullet item 2.0
149
150 =item *
151
152 Bullet item 3.0
153
154 =back
155
156 =cut
157 #
158 #
159 # Expected output.
160 #
161 #
162 * Bullet item 1.0
163 * Bullet item 2.0
164 * Bullet item 3.0
165
166 ###############################################################################
167 #
168 # NAME: Test for nested unordered (bullet) list, <ul>.
169 #
170 =pod
171
172 =over
173
174 =item *
175
176 Bullet item 1.0
177
178 =over
179
180 =item *
181
182 Bullet item 1.1
183
184 =over
185
186 =item *
187
188 Bullet item 1.2
189
190 =item *
191
192 Bullet item 2.2
193
194 =back
195
196
197 =item *
198
199 Bullet item 2.1
200
201 =back
202
203 =item *
204
205 Bullet item 2.0
206
207 =back
208
209 =cut
210 #
211 #
212 # Expected output.
213 #
214 #
215 * Bullet item 1.0
216 * Bullet item 1.1
217 * Bullet item 1.2
218 * Bullet item 2.2
219 * Bullet item 2.1
220 * Bullet item 2.0
221
222 ################################################################################
223 #
224 # NAME: Test for single ordered (number) item.
225 #
226 =pod
227
228 =over
229
230 =item 1
231
232 Number item
233
234 =back
235
236 =cut
237 #
238 #
239 # Expected output.
240 #
241 #
242 1. Number item
243
244 ###############################################################################
245 #
246 # NAME: Test for ordered (number) list, <ol>.
247 #
248 =pod
249
250 =over
251
252 =item 1
253
254 Number item 1.0
255
256 =item 2
257
258 Number item 2.0
259
260 =item 3
261
262 Number item 3.0
263
264 =back
265
266 =cut
267 #
268 #
269 # Expected output.
270 #
271 #
272 1. Number item 1.0
273 2. Number item 2.0
274 3. Number item 3.0
275
276 ###############################################################################
277 #
278 # NAME: Test for nested ordered (number) list, <ol>.
279 #
280 =pod
281
282 =over
283
284 =item 1
285
286 Number item 1.0
287
288 =over
289
290 =item 1
291
292 Number item 1.1
293
294 =over
295
296 =item 1
297
298 Number item 1.2
299
300 =item 2
301
302 Number item 2.2
303
304 =back
305
306 =item 2
307
308 Number item 2.1
309
310 =back
311
312 =item 2
313
314 Number item 2.0
315
316 =back
317
318 =cut
319 #
320 #
321 # Expected output.
322 #
323 #
324 1. Number item 1.0
325 1. Number item 1.1
326 1. Number item 1.2
327 2. Number item 2.2
328 2. Number item 2.1
329 2. Number item 2.0
330
331 ################################################################################
332 #
333 # NAME: Test for single definition list item.
334 #
335 =pod
336
337 =over
338
339 =item Foo
340
341 Definition item
342
343 =back
344
345 =cut
346 #
347 #
348 # Expected output.
349 #
350 #
351 $ Foo: Definition item
352
353 ###############################################################################
354 #
355 # NAME: Test for definition list, <dl>.
356 #
357 =pod
358
359 =over
360
361 =item Foo
362
363 Definition item 1.0
364
365 =item Bar
366
367 Definition item 2.0
368
369 =item Baz
370
371 Definition item 3.0
372
373 =back
374
375 =cut
376 #
377 #
378 # Expected output.
379 #
380 #
381 $ Foo: Definition item 1.0
382 $ Bar: Definition item 2.0
383 $ Baz: Definition item 3.0
384
385 ###############################################################################
386 #
387 # NAME: Test for nested definition list, <dl>.
388 #
389 =pod
390
391 =over
392
393 =item Foo
394
395 Definition item 1.0
396
397 =over
398
399 =item Foo
400
401 Definition item 1.1
402
403 =over
404
405 =item Foo
406
407 Definition item 1.2
408
409 =item Bar
410
411 Definition item 2.2
412
413 =back
414
415 =item Bar
416
417 Definition item 2.1
418
419 =back
420
421 =item Bar
422
423 Definition item 2.0
424
425 =back
426
427 =cut
428 #
429 #
430 # Expected output.
431 #
432 #
433 $ Foo: Definition item 1.0
434 $ Foo: Definition item 1.1
435 $ Foo: Definition item 1.2
436 $ Bar: Definition item 2.2
437 $ Bar: Definition item 2.1
438 $ Bar: Definition item 2.0
439
440 ###############################################################################
441 #
442 # NAME: Test for varied nested list.
443 #
444 =pod
445
446 =over
447
448 =item *
449
450 Bullet item 1.0
451
452 =over
453
454 =item 1
455
456 Number item 1.1
457
458 =over
459
460 =item Foo
461
462 Definition item 1.2
463
464 =item Bar
465
466 Definition item 2.2
467
468 =back
469
470 =item 2
471
472 Number item 2.1
473
474 =back
475
476 =item *
477
478 Bullet item 2.0
479
480 =back
481
482 =cut
483 #
484 #
485 # Expected output.
486 #
487 #
488 * Bullet item 1.0
489 1. Number item 1.1
490 $ Foo: Definition item 1.2
491 $ Bar: Definition item 2.2
492 2. Number item 2.1
493 * Bullet item 2.0
494
495 ################################################################################
496 #
497 # NAME: Test for definition list without =items, <blockquote>.
498 #
499 # TODO: Fix this later.
500 #
501 =pod
502
503 =over
504
505 This is a long sentence that forms part of a definition block.
506
507 =back
508
509 =cut
510 #
511 #
512 # Expected output.
513 #
514 #
515 : This is a long sentence that forms part of a definition block.
516
517 ################################################################################
518 #
519 # NAME: Test for definition list without a definition.
520 #
521 # TODO: Fix this later.
522 #
523 =pod
524
525 =over
526
527 =item This is a long sentence that forms part of a definition block.
528
529 =back
530
531 =cut
532 #
533 #
534 # Expected output.
535 #
536 #
537 $ This is a long sentence that forms part of a definition block.:
538
539 ###############################################################################
540 #
541 # End
542 #
543 ###############################################################################

  ViewVC Help
Powered by ViewVC 1.1.26