This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Upgrade to Pod-Simple-3.07
[perl5.git] / lib / Pod / t / pod-parser.t
CommitLineData
42ae9e1d 1#!/usr/bin/perl -w
42ae9e1d
RGS
2#
3# pod-parser.t -- Tests for backward compatibility with Pod::Parser.
4#
5# Copyright 2006 by Russ Allbery <rra@stanford.edu>
6#
7# This program is free software; you may redistribute it and/or modify it
8# under the same terms as Perl itself.
9
10BEGIN {
11 chdir 't' if -d 't';
12 if ($ENV{PERL_CORE}) {
13 @INC = '../lib';
14 } else {
15 unshift (@INC, '../blib/lib');
16 }
17 unshift (@INC, '../blib/lib');
18 $| = 1;
19 print "1..3\n";
20}
21
22END {
23 print "not ok 1\n" unless $loaded;
24}
25
26use Pod::Man;
27use Pod::Text;
28
29$loaded = 1;
30print "ok 1\n";
31
32my $parser = Pod::Man->new or die "Cannot create parser\n";
33open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n";
34print TMP "Some random B<text>.\n";
35close TMP;
36open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n";
37$parser->parse_from_file ({ -cutting => 0 }, 'tmp.pod', \*OUT);
38close OUT;
39open (OUT, 'out.tmp') or die "Cannot open out.tmp: $!\n";
40while (<OUT>) { last if /^\.nh/ }
41my $output;
42{
43 local $/;
44 $output = <OUT>;
45}
46close OUT;
47if ($output eq "Some random \\fBtext\\fR.\n") {
48 print "ok 2\n";
49} else {
50 print "not ok 2\n";
51 print "Expected\n========\nSome random \\fBtext\\fR.\n\n";
52 print "Output\n======\n$output\n";
53}
54
55$parser = Pod::Text->new or die "Cannot create parser\n";
56open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n";
57$parser->parse_from_file ({ -cutting => 0 }, 'tmp.pod', \*OUT);
58close OUT;
59open (OUT, 'out.tmp') or die "Cannot open out.tmp: $!\n";
60{
61 local $/;
62 $output = <OUT>;
63}
64close OUT;
65if ($output eq " Some random text.\n\n") {
66 print "ok 3\n";
67} else {
68 print "not ok 3\n";
69 print "Expected\n========\n Some random text.\n\n\n";
70 print "Output\n======\n$output\n";
71}
72
73unlink ('tmp.pod', 'out.tmp');
74exit 0;