[perl #45823] [PATCH] v5.8.8. pod2html: <a name="example"> anchor, but <a href="item_...
[p5sagit/p5-mst-13.2.git] / lib / Pod / t / pod-parser.t
CommitLineData
42ae9e1d 1#!/usr/bin/perl -w
2# $Id: pod-parser.t,v 1.2 2006-09-16 21:09:57 eagle Exp $
3#
4# pod-parser.t -- Tests for backward compatibility with Pod::Parser.
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 $parser = Pod::Man->new or die "Cannot create parser\n";
34open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n";
35print TMP "Some random B<text>.\n";
36close TMP;
37open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n";
38$parser->parse_from_file ({ -cutting => 0 }, 'tmp.pod', \*OUT);
39close OUT;
40open (OUT, 'out.tmp') or die "Cannot open out.tmp: $!\n";
41while (<OUT>) { last if /^\.nh/ }
42my $output;
43{
44 local $/;
45 $output = <OUT>;
46}
47close OUT;
48if ($output eq "Some random \\fBtext\\fR.\n") {
49 print "ok 2\n";
50} else {
51 print "not ok 2\n";
52 print "Expected\n========\nSome random \\fBtext\\fR.\n\n";
53 print "Output\n======\n$output\n";
54}
55
56$parser = Pod::Text->new or die "Cannot create parser\n";
57open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n";
58$parser->parse_from_file ({ -cutting => 0 }, 'tmp.pod', \*OUT);
59close OUT;
60open (OUT, 'out.tmp') or die "Cannot open out.tmp: $!\n";
61{
62 local $/;
63 $output = <OUT>;
64}
65close OUT;
66if ($output eq " Some random text.\n\n") {
67 print "ok 3\n";
68} else {
69 print "not ok 3\n";
70 print "Expected\n========\n Some random text.\n\n\n";
71 print "Output\n======\n$output\n";
72}
73
74unlink ('tmp.pod', 'out.tmp');
75exit 0;