1#!/usr/bin/perl -w 2# $Id: man.t,v 1.4 2003/01/05 06:31:52 eagle Exp $ 3# 4# man.t -- Additional specialized tests for Pod::Man. 5# 6# Copyright 2002, 2003 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 11BEGIN { 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; 20 print "1..5\n"; 21} 22 23END { 24 print "not ok 1\n" unless $loaded; 25} 26 27use Pod::Man; 28 29$loaded = 1; 30print "ok 1\n"; 31 32my $n = 2; 33while (<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 75gcc - GNU project C and C++ compiler 76 77=head1 C++ NOTES 78 79Other mentions of C++. 80### 81.SH "NAME" 82gcc \- GNU project C and C++ compiler 83.SH "\*(C+ NOTES" 84.IX Header " NOTES" 85Other mentions of \*(C+. 86### 87 88### 89=head1 PERIODS 90 91This C<.> should be quoted. 92### 93.SH "PERIODS" 94.IX Header "PERIODS" 95This \f(CW\*(C`.\*(C'\fR should be quoted. 96### 97 98### 99=over 4 100 101=item * 102 103A bullet. 104 105=item * 106 107Another bullet. 108 109=item * Not a bullet. 110 111=back 112### 113.IP "\(bu" 4 114A bullet. 115.IP "\(bu" 4 116Another bullet. 117.IP "* Not a bullet." 4 118.IX Item "Not a bullet." 119### 120 121### 122=over 4 123 124=item foo 125 126Not a bullet. 127 128=item * 129 130Also not a bullet. 131 132=back 133### 134.IP "foo" 4 135.IX Item "foo" 136Not a bullet. 137.IP "*" 4 138Also not a bullet. 139### 140