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