xref: /onnv-gate/usr/src/cmd/perl/5.8.4/distrib/lib/Pod/t/man.t (revision 0:68f95e015346)
1*0Sstevel@tonic-gate#!/usr/bin/perl -w
2*0Sstevel@tonic-gate# $Id: man.t,v 1.4 2003/01/05 06:31:52 eagle Exp $
3*0Sstevel@tonic-gate#
4*0Sstevel@tonic-gate# man.t -- Additional specialized tests for Pod::Man.
5*0Sstevel@tonic-gate#
6*0Sstevel@tonic-gate# Copyright 2002, 2003 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..5\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::Man;
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::Man->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    while (<TMP>) { last if /^\.TH/ }
45*0Sstevel@tonic-gate    my $output;
46*0Sstevel@tonic-gate    {
47*0Sstevel@tonic-gate        local $/;
48*0Sstevel@tonic-gate        $output = <TMP>;
49*0Sstevel@tonic-gate    }
50*0Sstevel@tonic-gate    close TMP;
51*0Sstevel@tonic-gate    unlink ('tmp.pod', 'out.tmp');
52*0Sstevel@tonic-gate    my $expected = '';
53*0Sstevel@tonic-gate    while (<DATA>) {
54*0Sstevel@tonic-gate        last if $_ eq "###\n";
55*0Sstevel@tonic-gate        $expected .= $_;
56*0Sstevel@tonic-gate    }
57*0Sstevel@tonic-gate    if ($output eq $expected) {
58*0Sstevel@tonic-gate        print "ok $n\n";
59*0Sstevel@tonic-gate    } else {
60*0Sstevel@tonic-gate        print "not ok $n\n";
61*0Sstevel@tonic-gate        print "Expected\n========\n$expected\nOutput\n======\n$output\n";
62*0Sstevel@tonic-gate    }
63*0Sstevel@tonic-gate    $n++;
64*0Sstevel@tonic-gate}
65*0Sstevel@tonic-gate
66*0Sstevel@tonic-gate# Below the marker are bits of POD and corresponding expected nroff output.
67*0Sstevel@tonic-gate# This is used to test specific features or problems with Pod::Man.  The input
68*0Sstevel@tonic-gate# and output are separated by lines containing only ###.
69*0Sstevel@tonic-gate
70*0Sstevel@tonic-gate__DATA__
71*0Sstevel@tonic-gate
72*0Sstevel@tonic-gate###
73*0Sstevel@tonic-gate=head1 NAME
74*0Sstevel@tonic-gate
75*0Sstevel@tonic-gategcc - GNU project C and C++ compiler
76*0Sstevel@tonic-gate
77*0Sstevel@tonic-gate=head1 C++ NOTES
78*0Sstevel@tonic-gate
79*0Sstevel@tonic-gateOther mentions of C++.
80*0Sstevel@tonic-gate###
81*0Sstevel@tonic-gate.SH "NAME"
82*0Sstevel@tonic-gategcc \- GNU project C and C++ compiler
83*0Sstevel@tonic-gate.SH "\*(C+ NOTES"
84*0Sstevel@tonic-gate.IX Header " NOTES"
85*0Sstevel@tonic-gateOther mentions of \*(C+.
86*0Sstevel@tonic-gate###
87*0Sstevel@tonic-gate
88*0Sstevel@tonic-gate###
89*0Sstevel@tonic-gate=head1 PERIODS
90*0Sstevel@tonic-gate
91*0Sstevel@tonic-gateThis C<.> should be quoted.
92*0Sstevel@tonic-gate###
93*0Sstevel@tonic-gate.SH "PERIODS"
94*0Sstevel@tonic-gate.IX Header "PERIODS"
95*0Sstevel@tonic-gateThis \f(CW\*(C`.\*(C'\fR should be quoted.
96*0Sstevel@tonic-gate###
97*0Sstevel@tonic-gate
98*0Sstevel@tonic-gate###
99*0Sstevel@tonic-gate=over 4
100*0Sstevel@tonic-gate
101*0Sstevel@tonic-gate=item *
102*0Sstevel@tonic-gate
103*0Sstevel@tonic-gateA bullet.
104*0Sstevel@tonic-gate
105*0Sstevel@tonic-gate=item    *
106*0Sstevel@tonic-gate
107*0Sstevel@tonic-gateAnother bullet.
108*0Sstevel@tonic-gate
109*0Sstevel@tonic-gate=item * Not a bullet.
110*0Sstevel@tonic-gate
111*0Sstevel@tonic-gate=back
112*0Sstevel@tonic-gate###
113*0Sstevel@tonic-gate.IP "\(bu" 4
114*0Sstevel@tonic-gateA bullet.
115*0Sstevel@tonic-gate.IP "\(bu" 4
116*0Sstevel@tonic-gateAnother bullet.
117*0Sstevel@tonic-gate.IP "* Not a bullet." 4
118*0Sstevel@tonic-gate.IX Item "Not a bullet."
119*0Sstevel@tonic-gate###
120*0Sstevel@tonic-gate
121*0Sstevel@tonic-gate###
122*0Sstevel@tonic-gate=over 4
123*0Sstevel@tonic-gate
124*0Sstevel@tonic-gate=item foo
125*0Sstevel@tonic-gate
126*0Sstevel@tonic-gateNot a bullet.
127*0Sstevel@tonic-gate
128*0Sstevel@tonic-gate=item *
129*0Sstevel@tonic-gate
130*0Sstevel@tonic-gateAlso not a bullet.
131*0Sstevel@tonic-gate
132*0Sstevel@tonic-gate=back
133*0Sstevel@tonic-gate###
134*0Sstevel@tonic-gate.IP "foo" 4
135*0Sstevel@tonic-gate.IX Item "foo"
136*0Sstevel@tonic-gateNot a bullet.
137*0Sstevel@tonic-gate.IP "*" 4
138*0Sstevel@tonic-gateAlso not a bullet.
139*0Sstevel@tonic-gate###
140