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