Commit | Line | Data |
---|---|---|
2da3dd12 | 1 | #!/usr/bin/perl -w |
f011ec7d | 2 | # $Id: man.t,v 1.2 2002/06/23 19:16:25 eagle Exp $ |
2da3dd12 AMS |
3 | # |
4 | # man.t -- Additional specialized tests for Pod::Man. | |
5 | # | |
6 | # Copyright 2002 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; | |
f011ec7d | 20 | print "1..3\n"; |
2da3dd12 AMS |
21 | } |
22 | ||
23 | END { | |
24 | print "not ok 1\n" unless $loaded; | |
25 | } | |
26 | ||
27 | use Pod::Man; | |
28 | ||
29 | $loaded = 1; | |
30 | print "ok 1\n"; | |
31 | ||
32 | my $n = 2; | |
33 | while (<DATA>) { | |
34 | next until $_ eq "###\n"; | |
35 | open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n"; | |
36 | while (<DATA>) { | |
37 | last if $_ eq "###\n"; | |
38 | print TMP $_; | |
39 | } | |
40 | close TMP; | |
41 | my $parser = Pod::Man->new or die "Cannot create parser\n"; | |
42 | $parser->parse_from_file ('tmp.pod', 'out.tmp'); | |
43 | open (TMP, 'out.tmp') or die "Cannot open out.tmp: $!\n"; | |
44 | while (<TMP>) { last if /^\.TH/ } | |
45 | my $output; | |
46 | { | |
47 | local $/; | |
48 | $output = <TMP>; | |
49 | } | |
50 | close TMP; | |
51 | unlink ('tmp.pod', 'out.tmp'); | |
52 | my $expected = ''; | |
53 | while (<DATA>) { | |
54 | last if $_ eq "###\n"; | |
55 | $expected .= $_; | |
56 | } | |
57 | if ($output eq $expected) { | |
58 | print "ok $n\n"; | |
59 | } else { | |
60 | print "not ok $n\n"; | |
61 | print "Expected\n========\n$expected\nOutput\n======\n$output\n"; | |
62 | } | |
63 | $n++; | |
64 | } | |
65 | ||
66 | # Below the marker are bits of POD and corresponding expected nroff output. | |
67 | # This is used to test specific features or problems with Pod::Man. The input | |
68 | # and output are separated by lines containing only ###. | |
69 | ||
70 | __DATA__ | |
71 | ||
72 | ### | |
73 | =head1 NAME | |
74 | ||
75 | gcc - GNU project C and C++ compiler | |
76 | ||
77 | =head1 C++ NOTES | |
78 | ||
79 | Other mentions of C++. | |
80 | ### | |
81 | .SH "NAME" | |
82 | gcc \- GNU project C and C++ compiler | |
83 | .SH "\*(C+ NOTES" | |
84 | .IX Header " NOTES" | |
85 | Other mentions of \*(C+. | |
86 | ### | |
f011ec7d JH |
87 | |
88 | ### | |
89 | =head1 PERIODS | |
90 | ||
91 | This C<.> should be quoted. | |
92 | ### | |
93 | .SH "PERIODS" | |
94 | .IX Header "PERIODS" | |
95 | This \f(CW\*(C`.\*(C'\fR should be quoted. | |
96 | ### |