Upgrade to podlators 2.0.5
[p5sagit/p5-mst-13.2.git] / lib / Pod / t / pod-parser.t
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
11 BEGIN {
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
23 END {
24     print "not ok 1\n" unless $loaded;
25 }
26
27 use Pod::Man;
28 use Pod::Text;
29
30 $loaded = 1;
31 print "ok 1\n";
32
33 my $parser = Pod::Man->new or die "Cannot create parser\n";
34 open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n";
35 print TMP "Some random B<text>.\n";
36 close TMP;
37 open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n";
38 $parser->parse_from_file ({ -cutting => 0 }, 'tmp.pod', \*OUT);
39 close OUT;
40 open (OUT, 'out.tmp') or die "Cannot open out.tmp: $!\n";
41 while (<OUT>) { last if /^\.nh/ }
42 my $output;
43 {
44     local $/;
45     $output = <OUT>;
46 }
47 close OUT;
48 if ($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";
57 open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n";
58 $parser->parse_from_file ({ -cutting => 0 }, 'tmp.pod', \*OUT);
59 close OUT;
60 open (OUT, 'out.tmp') or die "Cannot open out.tmp: $!\n";
61 {
62     local $/;
63     $output = <OUT>;
64 }
65 close OUT;
66 if ($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
74 unlink ('tmp.pod', 'out.tmp');
75 exit 0;