1 |
#!/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 |
|