/[socialtext-import]/Pod-Simple-Wiki/t/02_head_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

Annotation of /Pod-Simple-Wiki/t/02_head_twiki.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3 - (hide annotations)
Tue Nov 28 14:15:41 2006 UTC (17 years, 6 months ago) by dpavlin
File MIME type: application/x-troff
File size: 2022 byte(s)
import upstream Pod-Simple-Wiki-0.05.tar.gz
1 dpavlin 3 #!/usr/bin/perl -w
2    
3     ###############################################################################
4     #
5     # A test for Pod::Simple::Wiki.
6     #
7     # Tests for =head pod directives.
8     #
9     # reverse('©'), March 2005, Sam Tregar, sam@tregar.com
10     #
11    
12    
13     use strict;
14    
15     use Pod::Simple::Wiki;
16     use Test::More tests => 4;
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     [ "=pod\n\n=head1 Head 1" => qq(---+ Head 1\n\n) ],
25     [ "=pod\n\n=head2 Head 2" => qq(---++ Head 2\n\n) ],
26     [ "=pod\n\n=head3 Head 3" => qq(---+++ 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     $pod2 =~ s/</&lt;/g;
85     $pod2 =~ s/>/&gt;/g;
86    
87     print "Test ", $test++, ":\t", $pod2, "\n";
88     $parser->parse_string_document($pod);
89     print "\n----\n\n";
90     }
91     }
92    
93     __END__
94    
95    
96    

  ViewVC Help
Powered by ViewVC 1.1.26