/[socialtext-import]/Pod-Simple-Wiki/t/01_format_usemod.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_usemod.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3 - (hide annotations)
Tue Nov 28 14:15:41 2006 UTC (17 years, 5 months ago) by dpavlin
File MIME type: application/x-troff
File size: 2241 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('©'), August 2004, John McNamara, jmcnamara@cpan.org
10     #
11    
12    
13     use strict;
14    
15     use Pod::Simple::Wiki;
16     use Test::More tests => 6;
17    
18     my $style = 'usemod';
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(<i>Foo</i>\n\n) ],
26     [ "=pod\n\nB<Foo>" => qq(<b>Foo</b>\n\n) ],
27     [ "=pod\n\nC<Foo>" => qq(<tt>Foo</tt>\n\n) ],
28     [ "=pod\n\nF<Foo>" => qq(<i>Foo</i>\n\n) ],
29    
30     # Nested formatting tests
31     [ "=pod\n\nB<I<Foo>>" => qq(<b><i>Foo</i></b>\n\n)],
32     [ "=pod\n\nI<B<Foo>>" => qq(<i><b>Foo</b></i>\n\n)],
33     );
34    
35    
36     # TODO tests to fix later.
37     my @todo;
38    
39    
40     ###############################################################################
41     #
42     # Run the tests.
43     #
44     for my $test_ref (@tests) {
45    
46     my $parser = Pod::Simple::Wiki->new($style);
47     my $pod = $test_ref->[0];
48     my $target = $test_ref->[1];
49     my $wiki;
50    
51     $parser->output_string(\$wiki);
52     $parser->parse_string_document($pod);
53    
54    
55     is($wiki, $target, "\tTesting: " . encode_escapes($pod));
56     }
57    
58    
59     ###############################################################################
60     #
61     # Encode escapes to make them visible in the test output.
62     #
63     sub encode_escapes {
64     my $data = $_[0];
65    
66     for ($data) {
67     s/\t/\\t/g;
68     s/\n/\\n/g;
69     }
70    
71     return $data;
72     }
73    
74    
75     ###############################################################################
76     #
77     # Output the tests for visual testing in the wiki.
78     #
79     sub output_tests {
80    
81     my $test = 1;
82    
83     print "\n----\n\n";
84    
85     for my $test_ref (@tests) {
86    
87     my $parser = Pod::Simple::Wiki->new($style);
88     my $pod = $test_ref->[0];
89     my $pod2 = encode_escapes($pod);
90     $pod2 =~ s/^=pod\\n\\n//;
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