2 # $Id: basic.t,v 1.4 2002/01/28 02:56:19 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');
18 unshift (@INC, '../blib/lib');
24 print "not ok 1\n" unless $loaded;
30 use Pod::Text::Overstrike;
31 use Pod::Text::Termcap;
33 # Find the path to the test source files. This requires some fiddling when
34 # these tests are run as part of Perl core.
37 if ($ENV{PERL_CORE}) {
39 my $updir = File::Spec->updir;
40 my $dir = File::Spec->catdir ($updir, 'lib', 'Pod', 't');
41 return File::Spec->catfile ($dir, $file);
50 # Hard-code a few values to try to get reproducible results.
53 $ENV{TERMCAP} = 'xterm:co=80:do=^J:md=\E[1m:us=\E[4m:me=\E[m';
55 # Map of translators to file extensions to find the formatted output to
57 my %translators = ('Pod::Man' => 'man',
59 'Pod::Text::Color' => 'clr',
60 'Pod::Text::Overstrike' => 'ovr',
61 'Pod::Text::Termcap' => 'cap');
63 # Set default options to match those of pod2man and pod2text.
64 %options = (sentence => 0);
67 for (sort keys %translators) {
68 my $parser = $_->new (%options);
69 print (($parser && ref ($parser) eq $_) ? "ok $n\n" : "not ok $n\n");
72 # For Pod::Man, strip out the autogenerated header up to the .TH title
73 # line. That means that we don't check those things; oh well. The header
74 # changes with each version change or touch of the input file.
75 if ($_ eq 'Pod::Man') {
76 $parser->parse_from_file (source_path ('basic.pod'), 'out.tmp');
77 open (TMP, 'out.tmp') or die "Cannot open out.tmp: $!\n";
78 open (OUTPUT, "> out.$translators{$_}")
79 or die "Cannot create out.$translators{$_}: $!\n";
81 while (<TMP>) { last if /^\.TH/ }
82 print OUTPUT while <TMP>;
87 my $basic = source_path ('basic.pod');
88 $parser->parse_from_file ($basic, "out.$translators{$_}");
92 open (MASTER, source_path ("basic.$translators{$_}"))
93 or die "Cannot open basic.$translators{$_}: $!\n";
94 open (OUTPUT, "out.$translators{$_}")
95 or die "Cannot open out.$translators{$_}: $!\n";
96 my $master = <MASTER>;
97 my $output = <OUTPUT>;
101 # OS/390 is EBCDIC, which uses a different character for ESC
102 # apparently. Try to convert so that the test still works.
103 if ($^O eq 'os390' && $_ eq 'Pod::Text::Termcap') {
104 $output =~ tr/\033/\047/;
107 if ($master eq $output) {
109 unlink "out.$translators{$_}";
112 print "# Non-matching output left in out.$translators{$_}\n";