[perl #45823] [PATCH] v5.8.8. pod2html: <a name="example"> anchor, but <a href="item_...
[p5sagit/p5-mst-13.2.git] / lib / Pod / t / filehandle.t
CommitLineData
fcf69717 1#!/usr/bin/perl -w
42ae9e1d 2# $Id: filehandle.t,v 1.2 2006-09-16 20:25:25 eagle Exp $
fcf69717 3#
4# filehandle.t -- Test the parse_from_filehandle interface.
5#
6# Copyright 2006 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::Man;
28use Pod::Text;
29
30$loaded = 1;
31print "ok 1\n";
32
33my $man = Pod::Man->new or die "Cannot create parser\n";
34my $text = Pod::Text->new or die "Cannot create parser\n";
35my $n = 2;
36while (<DATA>) {
37 next until $_ eq "###\n";
38 open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n";
39 while (<DATA>) {
40 last if $_ eq "###\n";
41 print TMP $_;
42 }
43 close TMP;
44 open (IN, '< tmp.pod') or die "Cannot open tmp.pod: $!\n";
45 open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n";
46 $man->parse_from_filehandle (\*IN, \*OUT);
47 close IN;
48 close OUT;
49 open (OUT, 'out.tmp') or die "Cannot open out.tmp: $!\n";
42ae9e1d 50 while (<OUT>) { last if /^\.nh/ }
fcf69717 51 my $output;
52 {
53 local $/;
54 $output = <OUT>;
55 }
56 close OUT;
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 open (IN, '< tmp.pod') or die "Cannot open tmp.pod: $!\n";
70 open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n";
71 $text->parse_from_filehandle (\*IN, \*OUT);
72 close IN;
73 close OUT;
74 open (OUT, 'out.tmp') or die "Cannot open out.tmp: $!\n";
75 {
76 local $/;
77 $output = <OUT>;
78 }
79 close OUT;
80 unlink ('tmp.pod', 'out.tmp');
81 $expected = '';
82 while (<DATA>) {
83 last if $_ eq "###\n";
84 $expected .= $_;
85 }
86 if ($output eq $expected) {
87 print "ok $n\n";
88 } else {
89 print "not ok $n\n";
90 print "Expected\n========\n$expected\nOutput\n======\n$output\n";
91 }
92 $n++;
93}
94
95# Below the marker are bits of POD, corresponding expected nroff output, and
96# corresponding expected text output. The input and output are separated by
97# lines containing only ###.
98
99__DATA__
100
101###
102=head1 NAME
103
104gcc - GNU project C and C++ compiler
105
106=head1 C++ NOTES
107
108Other mentions of C++.
109###
110.SH "NAME"
111gcc \- GNU project C and C++ compiler
112.SH "\*(C+ NOTES"
113.IX Header " NOTES"
114Other mentions of \*(C+.
115###
116NAME
117 gcc - GNU project C and C++ compiler
118
119C++ NOTES
120 Other mentions of C++.
121
122###