File: pod-parser.t

package info (click to toggle)
perl 5.10.0-19lenny5
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 73,928 kB
  • ctags: 39,406
  • sloc: perl: 281,466; ansic: 182,157; sh: 37,027; pascal: 8,813; lisp: 7,515; cpp: 3,859; makefile: 2,320; xml: 1,972; yacc: 1,549
file content (75 lines) | stat: -rw-r--r-- 1,849 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/perl -w
# $Id: pod-parser.t,v 1.2 2006-09-16 21:09:57 eagle Exp $
#
# pod-parser.t -- Tests for backward compatibility with Pod::Parser.
#
# Copyright 2006 by Russ Allbery <rra@stanford.edu>
#
# This program is free software; you may redistribute it and/or modify it
# under the same terms as Perl itself.

BEGIN {
    chdir 't' if -d 't';
    if ($ENV{PERL_CORE}) {
        @INC = '../lib';
    } else {
        unshift (@INC, '../blib/lib');
    }
    unshift (@INC, '../blib/lib');
    $| = 1;
    print "1..3\n";
}

END {
    print "not ok 1\n" unless $loaded;
}

use Pod::Man;
use Pod::Text;

$loaded = 1;
print "ok 1\n";

my $parser = Pod::Man->new or die "Cannot create parser\n";
open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n";
print TMP "Some random B<text>.\n";
close TMP;
open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n";
$parser->parse_from_file ({ -cutting => 0 }, 'tmp.pod', \*OUT);
close OUT;
open (OUT, 'out.tmp') or die "Cannot open out.tmp: $!\n";
while (<OUT>) { last if /^\.nh/ }
my $output;
{
    local $/;
    $output = <OUT>;
}
close OUT;
if ($output eq "Some random \\fBtext\\fR.\n") {
    print "ok 2\n";
} else {
    print "not ok 2\n";
    print "Expected\n========\nSome random \\fBtext\\fR.\n\n";
    print "Output\n======\n$output\n";
}

$parser = Pod::Text->new or die "Cannot create parser\n";
open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n";
$parser->parse_from_file ({ -cutting => 0 }, 'tmp.pod', \*OUT);
close OUT;
open (OUT, 'out.tmp') or die "Cannot open out.tmp: $!\n";
{
    local $/;
    $output = <OUT>;
}
close OUT;
if ($output eq "    Some random text.\n\n") {
    print "ok 3\n";
} else {
    print "not ok 3\n";
    print "Expected\n========\n    Some random text.\n\n\n";
    print "Output\n======\n$output\n";
}

unlink ('tmp.pod', 'out.tmp');
exit 0;