3 # Purpose: test UserPreamble and UserPostamble
4 # It's a minor variation of 'pod2latex.t',
5 # subject to the same limitations.
7 # Adriano Rodrigues Ferreira <ferreira@triang.com.br>
12 BEGIN { plan tests => 17 }
16 # The link parsing changed between v0.22 and v0.30 of Pod::ParseUtils
18 my $linkver = $Pod::ParseUtils::VERSION;
20 # Set up an END block to remove the test output file
27 # First thing to do is to read the expected output from
28 # the DATA filehandle and store it in a scalar.
29 # Do this until we read an =pod
31 while (my $line = <DATA>) {
32 last if $line =~ /^=pod/;
33 push(@reference,$line);
36 my $user_preamble = <<PRE;
38 \\documentclass{article}
43 my $user_postamble = <<POST;
50 UserPreamble => $user_preamble,
51 UserPostamble => $user_postamble
54 my $parser = Pod::LaTeX->new(%params);
57 # Create an output file
58 open(OUTFH, "> test.tex" ) or die "Unable to open test tex file: $!\n";
60 # Read from the DATA filehandle and write to a new output file
61 # Really want to write this to a scalar
62 $parser->parse_from_filehandle(\*DATA,\*OUTFH);
64 close(OUTFH) or die "Error closing OUTFH test.tex: $!\n";
66 # Now read in OUTFH and compare
67 open(INFH, "< test.tex") or die "Unable to read test tex file: $!\n";
70 ok(@output, @reference);
72 for my $i (0..$#reference) {
73 next if $reference[$i] =~ /^%%/; # skip timestamp comments
74 ok($output[$i], $reference[$i]);
77 close(INFH) or die "Error closing INFH test.tex: $!\n";
82 \documentclass{article}
86 %% Latex generated from POD in document (unknown)
87 %% Using the perl module Pod::LaTeX
88 %% Converted on Wed Jan 14 19:04:22 2004
90 %% Preamble supplied by user.
92 \section{POD\label{POD}\index{POD}}
95 This is a POD file, very simple. \textit{Bye}.
103 This is a POD file, very simple. I<Bye>.