/[socialtext-import]/Pod-Simple-Wiki/t/03_lists_wiki.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_wiki.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: 6829 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 = 'wiki';
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 print "Test ", $test++, ":\t", $name, "\n";
99 $parser->parse_string_document($pod);
100 print "\n----\n\n";
101 }
102 }
103
104 __DATA__
105 ################################################################################
106 #
107 # Test data.
108 #
109 ################################################################################
110 #
111 # NAME: Test for single unordered (bullet) item.
112 #
113 =pod
114
115 =over
116
117 =item *
118
119 Bullet item
120
121 =back
122
123 =cut
124 #
125 #
126 # Expected output.
127 #
128 #
129 *Bullet item
130
131 ################################################################################
132 #
133 # NAME: Test for unordered (bullet) list, <ul>.
134 #
135 =pod
136
137 =over
138
139 =item *
140
141 Bullet item 1.0
142
143 =item *
144
145 Bullet item 2.0
146
147 =item *
148
149 Bullet item 3.0
150
151 =back
152
153 =cut
154 #
155 #
156 # Expected output.
157 #
158 #
159 *Bullet item 1.0
160 *Bullet item 2.0
161 *Bullet item 3.0
162
163 ###############################################################################
164 #
165 # NAME: Test for nested unordered (bullet) list, <ul>.
166 #
167 =pod
168
169 =over
170
171 =item *
172
173 Bullet item 1.0
174
175 =over
176
177 =item *
178
179 Bullet item 1.1
180
181 =over
182
183 =item *
184
185 Bullet item 1.2
186
187 =item *
188
189 Bullet item 2.2
190
191 =back
192
193
194 =item *
195
196 Bullet item 2.1
197
198 =back
199
200 =item *
201
202 Bullet item 2.0
203
204 =back
205
206 =cut
207 #
208 #
209 # Expected output.
210 #
211 #
212 *Bullet item 1.0
213 **Bullet item 1.1
214 ***Bullet item 1.2
215 ***Bullet item 2.2
216 **Bullet item 2.1
217 *Bullet item 2.0
218
219 ################################################################################
220 #
221 # NAME: Test for single ordered (number) item.
222 #
223 =pod
224
225 =over
226
227 =item 1
228
229 Number item
230
231 =back
232
233 =cut
234 #
235 #
236 # Expected output.
237 #
238 #
239 \t1Number item
240
241 ###############################################################################
242 #
243 # NAME: Test for ordered (number) list, <ol>.
244 #
245 =pod
246
247 =over
248
249 =item 1
250
251 Number item 1.0
252
253 =item 2
254
255 Number item 2.0
256
257 =item 3
258
259 Number item 3.0
260
261 =back
262
263 =cut
264 #
265 #
266 # Expected output.
267 #
268 #
269 \t1Number item 1.0
270 \t2Number item 2.0
271 \t3Number item 3.0
272
273 ###############################################################################
274 #
275 # NAME: Test for nested ordered (number) list, <ol>.
276 #
277 =pod
278
279 =over
280
281 =item 1
282
283 Number item 1.0
284
285 =over
286
287 =item 1
288
289 Number item 1.1
290
291 =over
292
293 =item 1
294
295 Number item 1.2
296
297 =item 2
298
299 Number item 2.2
300
301 =back
302
303 =item 2
304
305 Number item 2.1
306
307 =back
308
309 =item 2
310
311 Number item 2.0
312
313 =back
314
315 =cut
316 #
317 #
318 # Expected output.
319 #
320 #
321 \t1Number item 1.0
322 \t\t1Number item 1.1
323 \t\t\t1Number item 1.2
324 \t\t\t2Number item 2.2
325 \t\t2Number item 2.1
326 \t2Number item 2.0
327
328 ################################################################################
329 #
330 # NAME: Test for single definition list item.
331 #
332 =pod
333
334 =over
335
336 =item Foo
337
338 Definition item
339
340 =back
341
342 =cut
343 #
344 #
345 # Expected output.
346 #
347 #
348 \tFoo:\tDefinition item
349
350 ###############################################################################
351 #
352 # NAME: Test for definition list, <dl>.
353 #
354 =pod
355
356 =over
357
358 =item Foo
359
360 Definition item 1.0
361
362 =item Bar
363
364 Definition item 2.0
365
366 =item Baz
367
368 Definition item 3.0
369
370 =back
371
372 =cut
373 #
374 #
375 # Expected output.
376 #
377 #
378 \tFoo:\tDefinition item 1.0
379 \tBar:\tDefinition item 2.0
380 \tBaz:\tDefinition item 3.0
381
382 ###############################################################################
383 #
384 # NAME: Test for nested definition list, <dl>.
385 #
386 =pod
387
388 =over
389
390 =item Foo
391
392 Definition item 1.0
393
394 =over
395
396 =item Foo
397
398 Definition item 1.1
399
400 =over
401
402 =item Foo
403
404 Definition item 1.2
405
406 =item Bar
407
408 Definition item 2.2
409
410 =back
411
412 =item Bar
413
414 Definition item 2.1
415
416 =back
417
418 =item Bar
419
420 Definition item 2.0
421
422 =back
423
424 =cut
425 #
426 #
427 # Expected output.
428 #
429 #
430 \tFoo:\tDefinition item 1.0
431 \t\tFoo:\tDefinition item 1.1
432 \t\t\tFoo:\tDefinition item 1.2
433 \t\t\tBar:\tDefinition item 2.2
434 \t\tBar:\tDefinition item 2.1
435 \tBar:\tDefinition item 2.0
436
437 ###############################################################################
438 #
439 # NAME: Test for varied nested list.
440 #
441 =pod
442
443 =over
444
445 =item *
446
447 Bullet item 1.0
448
449 =over
450
451 =item 1
452
453 Number item 1.1
454
455 =over
456
457 =item Foo
458
459 Definition item 1.2
460
461 =item Bar
462
463 Definition item 2.2
464
465 =back
466
467 =item 2
468
469 Number item 2.1
470
471 =back
472
473 =item *
474
475 Bullet item 2.0
476
477 =back
478
479 =cut
480 #
481 #
482 # Expected output.
483 #
484 #
485 *Bullet item 1.0
486 \t\t1Number item 1.1
487 \t\t\tFoo:\tDefinition item 1.2
488 \t\t\tBar:\tDefinition item 2.2
489 \t\t2Number item 2.1
490 *Bullet item 2.0
491
492 ################################################################################
493 #
494 # NAME: Test for definition list without =items, <blockquote>.
495 #
496 =pod
497
498 =over
499
500 This is a long sentence that forms part of a definition block.
501
502 =back
503
504 =cut
505 #
506 #
507 # Expected output.
508 #
509 #
510 \t :\tThis is a long sentence that forms part of a definition block.
511
512 ################################################################################
513 #
514 # NAME: Test for definition list without a definition.
515 #
516 # TODO: Fix this later.
517 #
518 =pod
519
520 =over
521
522 =item This is a long sentence that forms part of a definition block.
523
524 =back
525
526 =cut
527 #
528 #
529 # Expected output.
530 #
531 #
532 \tThis is a long sentence that forms part of a definition block.:\t
533
534 ###############################################################################
535 #
536 # End
537 #
538 ###############################################################################

  ViewVC Help
Powered by ViewVC 1.1.26