/[socialtext-import]/Pod-Simple-Wiki/t/02_head_kwiki.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/02_head_kwiki.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: 1972 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 =head pod directives.
8 #
9 # reverse('©'), August 2004, John McNamara, jmcnamara@cpan.org
10 #
11
12
13 use strict;
14
15 use Pod::Simple::Wiki;
16 use Test::More tests => 4;
17
18 my $style = 'kwiki';
19
20 # Output the tests for visual testing in the wiki.
21 # END{output_tests()};
22
23 my @tests = (
24 [ "=pod\n\n=head1 Head 1" => qq(\n----\n= Head 1 =\n\n)],
25 [ "=pod\n\n=head2 Head 2" => qq(\n== Head 2 ==\n\n) ],
26 [ "=pod\n\n=head3 Head 3" => qq(\n=== Head 3 ===\n\n) ],
27 [ "=pod\n\n=head4 Head 4" => qq(==== Head 4\n\n) ],
28 );
29
30
31
32
33 ###############################################################################
34 #
35 # Run the tests.
36 #
37 for my $test_ref (@tests) {
38
39 my $parser = Pod::Simple::Wiki->new($style);
40 my $pod = $test_ref->[0];
41 my $target = $test_ref->[1];
42 my $wiki;
43
44 $parser->output_string(\$wiki);
45 $parser->parse_string_document($pod);
46
47
48 is($wiki, $target, "\tTesting: " . encode_escapes($pod));
49 }
50
51
52 ###############################################################################
53 #
54 # Encode escapes to make them visible in the test output.
55 #
56 sub encode_escapes {
57 my $data = $_[0];
58
59 for ($data) {
60 s/\t/\\t/g;
61 s/\n/\\n/g;
62 }
63
64 return $data;
65 }
66
67
68 ###############################################################################
69 #
70 # Output the tests for visual testing in the wiki.
71 #
72 sub output_tests {
73
74 my $test = 1;
75
76 print "\n----\n\n";
77
78 for my $test_ref (@tests) {
79
80 my $parser = Pod::Simple::Wiki->new($style);
81 my $pod = $test_ref->[0];
82 my $pod2 = encode_escapes($pod);
83 $pod2 =~ s/^=pod\\n\\n//;
84
85 print "Test ", $test++, ":\t", $pod2, "\n";
86 $parser->parse_string_document($pod);
87 print "\n----\n\n";
88 }
89 }
90
91 __END__
92
93
94

  ViewVC Help
Powered by ViewVC 1.1.26