/[socialtext-import]/Pod-Simple-Wiki/t/01_format_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/01_format_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: 2351 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 I<>, B<>, C<> etc., formatting codes.
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 => 6;
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     # Simple formatting tests
25     [ "=pod\n\nI<Foo>" => qq(_Foo_\n\n) ],
26     [ "=pod\n\nB<Foo>" => qq(*Foo*\n\n) ],
27     [ "=pod\n\nC<Foo>" => qq(=Foo=\n\n) ],
28     [ "=pod\n\nF<Foo>" => qq(_Foo_\n\n) ],
29    
30     # Nested formatting tests
31     [ "=pod\n\nB<I<Foo>>" => qq(*_Foo_*\n\n) ],
32     [ "=pod\n\nI<B<Foo>>" => qq(__Foo__\n\n),
33     'Fix this later.' ],
34     );
35    
36    
37     ###############################################################################
38     #
39     # Run the tests.
40     #
41     for my $test_ref (@tests) {
42    
43     my $parser = Pod::Simple::Wiki->new($style);
44     my $pod = $test_ref->[0];
45     my $target = $test_ref->[1];
46     my $todo = $test_ref->[2];
47     my $wiki;
48    
49     $parser->output_string(\$wiki);
50     $parser->parse_string_document($pod);
51    
52     local $TODO = $todo;
53     is($wiki, $target, "\tTesting: " . encode_escapes($pod));
54     }
55    
56    
57     ###############################################################################
58     #
59     # Encode escapes to make them visible in the test output.
60     #
61     sub encode_escapes {
62     my $data = $_[0];
63    
64     for ($data) {
65     s/\t/\\t/g;
66     s/\n/\\n/g;
67     }
68    
69     return $data;
70     }
71    
72    
73     ###############################################################################
74     #
75     # Output the tests for visual testing in the wiki.
76     #
77     sub output_tests {
78    
79     my $test = 1;
80    
81     print "\n----\n\n";
82    
83     for my $test_ref (@tests) {
84    
85     my $parser = Pod::Simple::Wiki->new($style);
86     my $pod = $test_ref->[0];
87     my $pod2 = encode_escapes($pod);
88     $pod2 =~ s/^=pod\\n\\n//;
89     $pod2 =~ s/</&lt;/g;
90     $pod2 =~ s/>/&gt;/g;
91    
92     print "Test ", $test++, ":\t", $pod2, "\n";
93     $parser->parse_string_document($pod);
94     print "\n----\n\n";
95     }
96     }
97    
98     __END__
99    
100    
101    

  ViewVC Help
Powered by ViewVC 1.1.26