File: 09_01_textile_format.t

package info (click to toggle)
libpod-simple-wiki-perl 0.11-1
  • links: PTS
  • area: main
  • in suites: squeeze, wheezy
  • size: 324 kB
  • ctags: 110
  • sloc: perl: 2,485; makefile: 44
file content (81 lines) | stat: -rw-r--r-- 1,960 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/perl -w

###############################################################################
#
# A test for Pod::Simple::Wiki.
#
# Tests for I<>, B<>, C<> etc., formatting codes.
#
# reverse(''), December 2005, John McNamara, jmcnamara@cpan.org
#


use strict;

use Pod::Simple::Wiki;
use Test::More tests => 6;

my $style = 'textile';

# Output the tests for visual testing in the wiki.
# END{output_tests()};

my @tests  = (
                # Simple formatting tests
                [ "=pod\n\nI<Foo>"      => qq(_Foo_\n\n),       'Italic'     ],
                [ "=pod\n\nB<Foo>"      => qq(*Foo*\n\n),       'Bold'       ],
                [ "=pod\n\nC<Foo>"      => qq(\@Foo\@\n\n),     'Monospace'  ],
                [ "=pod\n\nF<Foo>"      => qq(_Foo_\n\n),       'Filename'   ],

                # Nested formatting tests
                [ "=pod\n\nB<I<Foo>>"   => qq(*_Foo_*\n\n), 'Bold Italic'],
                [ "=pod\n\nI<B<Foo>>"   => qq(_*Foo*_\n\n), 'Italic Bold'],
);



###############################################################################
#
#  Run the tests.
#
for my $test_ref (@tests) {

    my $parser  = Pod::Simple::Wiki->new($style);
    my $pod     = $test_ref->[0];
    my $target  = $test_ref->[1];
    my $name    = $test_ref->[2];
    my $wiki;

    $parser->output_string(\$wiki);
    $parser->parse_string_document($pod);

    is($wiki, $target, "\tTesting: $name");
}


###############################################################################
#
# Output the tests for visual testing in the wiki.
#
sub output_tests {

    my $test = 1;

    print "\n\n";

    for my $test_ref (@tests) {

        my $parser  =  Pod::Simple::Wiki->new($style);
        my $pod     =  $test_ref->[0];
        my $name    =  $test_ref->[2];

        $pod        =~ s/=pod\n\n//;
        $pod        = "=pod\n\n=head2 Test ". $test++ . " $name\n\n$pod";

        $parser->parse_string_document($pod);
    }
}


__END__