2 # $Id: basic.t,v 1.1 2001/11/23 10:09:06 eagle Exp $
4 # basic.t -- Basic tests for podlators.
6 # Copyright 2001 by Russ Allbery <rra@stanford.edu>
8 # This program is free software; you may redistribute it and/or modify it
9 # under the same terms as Perl itself.
13 unshift (@INC, '../blib/lib');
19 print "not ok 1\n" unless $loaded;
25 use Pod::Text::Overstrike;
26 use Pod::Text::Termcap;
31 # Hard-code a few values to try to get reproducible results.
32 @ENV{qw(TERMCAP COLUMNS)} = ('co=80:do=^J:md=\E[1m:us=\E[4m:me=\E[m', 80);
34 # Map of translators to file extensions to find the formatted output to
36 my %translators = ('Pod::Man' => 'man',
38 'Pod::Text::Color' => 'clr',
39 'Pod::Text::Overstrike' => 'ovr',
40 'Pod::Text::Termcap' => 'cap');
42 # Set default options to match those of pod2man and pod2text.
43 %options = (sentence => 0);
46 for (sort keys %translators) {
47 my $parser = $_->new (%options);
48 print (($parser && ref ($parser) eq $_) ? "ok $n\n" : "not ok $n\n");
51 # For Pod::Man, strip out the autogenerated header up to the .TH title
52 # line. That means that we don't check those things; oh well. The header
53 # changes with each version change or touch of the input file.
54 if ($_ eq 'Pod::Man') {
55 $parser->parse_from_file ('basic.pod', 'out.tmp');
56 open (TMP, 'out.tmp') or die "Cannot open out.tmp: $!\n";
57 open (OUTPUT, "> out.$translators{$_}")
58 or die "Cannot create out.$translators{$_}: $!\n";
60 while (<TMP>) { last if /^\.TH/ }
61 print OUTPUT while <TMP>;
66 $parser->parse_from_file ('basic.pod', "out.$translators{$_}");
70 open (MASTER, "basic.$translators{$_}")
71 or die "Cannot open basic.$translators{$_}: $!\n";
72 open (OUTPUT, "out.$translators{$_}")
73 or die "Cannot open out.$translators{$_}: $!\n";
74 my $master = <MASTER>;
75 my $output = <OUTPUT>;
78 if ($master eq $output) {
80 unlink "out.$translators{$_}";
83 print "# Non-matching output left in out.$translators{$_}\n";