xref: /onnv-gate/usr/src/cmd/perl/5.8.4/distrib/lib/Pod/t/text.t (revision 0:68f95e015346)
1*0Sstevel@tonic-gate#!/usr/bin/perl -w
2*0Sstevel@tonic-gate# $Id: text.t,v 1.1 2002/06/23 19:16:25 eagle Exp $
3*0Sstevel@tonic-gate#
4*0Sstevel@tonic-gate# text.t -- Additional specialized tests for Pod::Text.
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..2\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    next until $_ eq "###\n";
35*0Sstevel@tonic-gate    open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n";
36*0Sstevel@tonic-gate    while (<DATA>) {
37*0Sstevel@tonic-gate        last if $_ eq "###\n";
38*0Sstevel@tonic-gate        print TMP $_;
39*0Sstevel@tonic-gate    }
40*0Sstevel@tonic-gate    close TMP;
41*0Sstevel@tonic-gate    my $parser = Pod::Text->new or die "Cannot create parser\n";
42*0Sstevel@tonic-gate    $parser->parse_from_file ('tmp.pod', 'out.tmp');
43*0Sstevel@tonic-gate    open (TMP, 'out.tmp') or die "Cannot open out.tmp: $!\n";
44*0Sstevel@tonic-gate    my $output;
45*0Sstevel@tonic-gate    {
46*0Sstevel@tonic-gate        local $/;
47*0Sstevel@tonic-gate        $output = <TMP>;
48*0Sstevel@tonic-gate    }
49*0Sstevel@tonic-gate    close TMP;
50*0Sstevel@tonic-gate    unlink ('tmp.pod', 'out.tmp');
51*0Sstevel@tonic-gate    my $expected = '';
52*0Sstevel@tonic-gate    while (<DATA>) {
53*0Sstevel@tonic-gate        last if $_ eq "###\n";
54*0Sstevel@tonic-gate        $expected .= $_;
55*0Sstevel@tonic-gate    }
56*0Sstevel@tonic-gate    if ($output eq $expected) {
57*0Sstevel@tonic-gate        print "ok $n\n";
58*0Sstevel@tonic-gate    } else {
59*0Sstevel@tonic-gate        print "not ok $n\n";
60*0Sstevel@tonic-gate        print "Expected\n========\n$expected\nOutput\n======\n$output\n";
61*0Sstevel@tonic-gate    }
62*0Sstevel@tonic-gate    $n++;
63*0Sstevel@tonic-gate}
64*0Sstevel@tonic-gate
65*0Sstevel@tonic-gate# Below the marker are bits of POD and corresponding expected text output.
66*0Sstevel@tonic-gate# This is used to test specific features or problems with Pod::Text.  The
67*0Sstevel@tonic-gate# input and output are separated by lines containing only ###.
68*0Sstevel@tonic-gate
69*0Sstevel@tonic-gate__DATA__
70*0Sstevel@tonic-gate
71*0Sstevel@tonic-gate###
72*0Sstevel@tonic-gate=head1 PERIODS
73*0Sstevel@tonic-gate
74*0Sstevel@tonic-gateThis C<.> should be quoted.
75*0Sstevel@tonic-gate###
76*0Sstevel@tonic-gatePERIODS
77*0Sstevel@tonic-gate    This "." should be quoted.
78*0Sstevel@tonic-gate
79*0Sstevel@tonic-gate###
80