xref: /onnv-gate/usr/src/cmd/perl/5.8.4/distrib/lib/Pod/t/text-options.t (revision 0:68f95e015346)
1#!/usr/bin/perl -w
2# $Id: text-options.t,v 1.2 2002/08/04 03:38:24 eagle Exp $
3#
4# text-options.t -- Additional tests for Pod::Text options.
5#
6# Copyright 2002 by Russ Allbery <rra@stanford.edu>
7#
8# This program is free software; you may redistribute it and/or modify it
9# under the same terms as Perl itself.
10
11BEGIN {
12    chdir 't' if -d 't';
13    if ($ENV{PERL_CORE}) {
14        @INC = '../lib';
15    } else {
16        unshift (@INC, '../blib/lib');
17    }
18    unshift (@INC, '../blib/lib');
19    $| = 1;
20    print "1..3\n";
21}
22
23END {
24    print "not ok 1\n" unless $loaded;
25}
26
27use Pod::Text;
28
29$loaded = 1;
30print "ok 1\n";
31
32my $n = 2;
33while (<DATA>) {
34    my %options;
35    next until $_ eq "###\n";
36    while (<DATA>) {
37        last if $_ eq "###\n";
38        my ($option, $value) = split;
39        $options{$option} = $value;
40    }
41    open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n";
42    while (<DATA>) {
43        last if $_ eq "###\n";
44        print TMP $_;
45    }
46    close TMP;
47    my $parser = Pod::Text->new (%options) or die "Cannot create parser\n";
48    $parser->parse_from_file ('tmp.pod', 'out.tmp');
49    open (TMP, 'out.tmp') or die "Cannot open out.tmp: $!\n";
50    my $output;
51    {
52        local $/;
53        $output = <TMP>;
54    }
55    close TMP;
56    unlink ('tmp.pod', 'out.tmp');
57    my $expected = '';
58    while (<DATA>) {
59        last if $_ eq "###\n";
60        $expected .= $_;
61    }
62    if ($output eq $expected) {
63        print "ok $n\n";
64    } else {
65        print "not ok $n\n";
66        print "Expected\n========\n$expected\nOutput\n======\n$output\n";
67    }
68    $n++;
69}
70
71# Below the marker are bits of POD and corresponding expected text output.
72# This is used to test specific features or problems with Pod::Text.  The
73# input and output are separated by lines containing only ###.
74
75__DATA__
76
77###
78alt 1
79###
80=head1 SAMPLE
81
82=over 4
83
84=item F
85
86Paragraph.
87
88=item Bar
89
90=item B
91
92Paragraph.
93
94=item Longer
95
96Paragraph.
97
98=back
99
100###
101
102==== SAMPLE ====
103
104:   F   Paragraph.
105
106:   Bar
107:   B   Paragraph.
108
109:   Longer
110        Paragraph.
111
112###
113
114###
115margin 4
116###
117=head1 SAMPLE
118
119This is some body text that is long enough to be a paragraph that wraps,
120thereby testing margins with wrapped paragraphs.
121
122 This is some verbatim text.
123
124=over 6
125
126=item Test
127
128This is a test of an indented paragraph.
129
130This is another indented paragraph.
131
132=back
133###
134    SAMPLE
135        This is some body text that is long enough to be a paragraph that
136        wraps, thereby testing margins with wrapped paragraphs.
137
138         This is some verbatim text.
139
140        Test  This is a test of an indented paragraph.
141
142              This is another indented paragraph.
143
144###
145