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 if ($ENV{PERL_CORE}) {
16 unshift (@INC, '../blib/lib');
23 print "not ok 1\n" unless $loaded;
29 use Pod::Text::Overstrike;
30 use Pod::Text::Termcap;
35 # Hard-code a few values to try to get reproducible results.
36 @ENV{qw(TERMCAP COLUMNS)} = ('co=80:do=^J:md=\E[1m:us=\E[4m:me=\E[m', 80);
38 # Map of translators to file extensions to find the formatted output to
40 my %translators = ('Pod::Man' => 'man',
42 'Pod::Text::Color' => 'clr',
43 'Pod::Text::Overstrike' => 'ovr',
44 # 'Pod::Text::Termcap' => 'cap' # unportable
47 # Set default options to match those of pod2man and pod2text.
48 %options = (sentence => 0);
52 if ($ENV{PERL_CORE}) {
54 return File::Spec->catfile(File::Spec->catdir(File::Spec->updir,
62 for (sort keys %translators) {
63 my $parser = $_->new (%options);
64 print (($parser && ref ($parser) eq $_) ? "ok $n\n" : "not ok $n\n");
67 # For Pod::Man, strip out the autogenerated header up to the .TH title
68 # line. That means that we don't check those things; oh well. The header
69 # changes with each version change or touch of the input file.
70 if ($_ eq 'Pod::Man') {
71 $parser->parse_from_file (basic("basic.pod"), 'out.tmp');
72 open (TMP, 'out.tmp') or die "Cannot open out.tmp: $!\n";
73 open (OUTPUT, "> out.$translators{$_}")
74 or die "Cannot create out.$translators{$_}: $!\n";
76 while (<TMP>) { last if /^\.TH/ }
77 print OUTPUT while <TMP>;
82 $parser->parse_from_file (basic("basic.pod"), "out.$translators{$_}");
86 open (MASTER, basic("basic.$translators{$_}"))
87 or die "Cannot open basic.$translators{$_}: $!\n";
88 open (OUTPUT, "out.$translators{$_}")
89 or die "Cannot open out.$translators{$_}: $!\n";
90 my $master = <MASTER>;
91 my $output = <OUTPUT>;
94 if ($master eq $output) {
96 unlink "out.$translators{$_}";
99 print "# Non-matching output left in out.$translators{$_}\n";