Mark all .t and .pm files as non executable
[p5sagit/p5-mst-13.2.git] / lib / Pod / t / pod-parser.t
CommitLineData
42ae9e1d 1#!/usr/bin/perl -w
42ae9e1d 2#
3# pod-parser.t -- Tests for backward compatibility with Pod::Parser.
4#
eccdc4d7 5# Copyright 2006, 2008 by Russ Allbery <rra@stanford.edu>
42ae9e1d 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;
eccdc4d7 19 print "1..4\n";
42ae9e1d 20}
21
eccdc4d7 22my $loaded;
23
42ae9e1d 24END {
25 print "not ok 1\n" unless $loaded;
26}
27
28use Pod::Man;
29use Pod::Text;
eccdc4d7 30use strict;
42ae9e1d 31
32$loaded = 1;
33print "ok 1\n";
34
35my $parser = Pod::Man->new or die "Cannot create parser\n";
36open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n";
37print TMP "Some random B<text>.\n";
38close TMP;
39open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n";
40$parser->parse_from_file ({ -cutting => 0 }, 'tmp.pod', \*OUT);
41close OUT;
42open (OUT, 'out.tmp') or die "Cannot open out.tmp: $!\n";
43while (<OUT>) { last if /^\.nh/ }
44my $output;
45{
46 local $/;
47 $output = <OUT>;
48}
49close OUT;
50if ($output eq "Some random \\fBtext\\fR.\n") {
51 print "ok 2\n";
52} else {
53 print "not ok 2\n";
54 print "Expected\n========\nSome random \\fBtext\\fR.\n\n";
55 print "Output\n======\n$output\n";
56}
57
58$parser = Pod::Text->new or die "Cannot create parser\n";
59open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n";
60$parser->parse_from_file ({ -cutting => 0 }, 'tmp.pod', \*OUT);
61close OUT;
62open (OUT, 'out.tmp') or die "Cannot open out.tmp: $!\n";
63{
64 local $/;
65 $output = <OUT>;
66}
67close OUT;
68if ($output eq " Some random text.\n\n") {
69 print "ok 3\n";
70} else {
71 print "not ok 3\n";
72 print "Expected\n========\n Some random text.\n\n\n";
73 print "Output\n======\n$output\n";
74}
75
eccdc4d7 76# Test the pod2text function, particularly with only one argument.
77open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n";
78print TMP "=pod\n\nSome random B<text>.\n";
79close TMP;
80open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n";
81open (SAVE, '>&STDOUT') or die "Cannot dup stdout: $!\n";
82open (STDOUT, '>&OUT') or die "Cannot replace stdout: $!\n";
83pod2text ('tmp.pod');
84close OUT;
85open (STDOUT, '>&SAVE') or die "Cannot fix stdout: $!\n";
86close SAVE;
87open (OUT, 'out.tmp') or die "Cannot open out.tmp: $!\n";
88{
89 local $/;
90 $output = <OUT>;
91}
92close OUT;
93if ($output eq " Some random text.\n\n") {
94 print "ok 4\n";
95} else {
96 print "not ok 4\n";
97 print "Expected\n========\n Some random text.\n\n\n";
98 print "Output\n======\n$output\n";
99}
100
42ae9e1d 101unlink ('tmp.pod', 'out.tmp');
102exit 0;