This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Upgrade to Pod-Simple-3.07
[perl5.git] / lib / Pod / t / user.t
CommitLineData
72e5dea6
RGS
1#!perl
2
3# Purpose: test UserPreamble and UserPostamble
4# It's a minor variation of 'pod2latex.t',
5# subject to the same limitations.
6# Variant provided by
7# Adriano Rodrigues Ferreira <ferreira@triang.com.br>
8
9use Test;
10use strict;
11
12BEGIN { plan tests => 17 }
13
14use Pod::LaTeX;
15
16# The link parsing changed between v0.22 and v0.30 of Pod::ParseUtils
17use Pod::ParseUtils;
18my $linkver = $Pod::ParseUtils::VERSION;
19
20# Set up an END block to remove the test output file
21END {
22 unlink "test.tex";
23};
24
25ok(1);
26
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
30my @reference;
31while (my $line = <DATA>) {
32 last if $line =~ /^=pod/;
33 push(@reference,$line);
34}
35
36my $user_preamble = <<PRE;
37
38\\documentclass{article}
39
40\\begin{document}
41PRE
42
43my $user_postamble = <<POST;
44\\end{document}
45
46POST
47
48# Create a new parser
49my %params = (
50 UserPreamble => $user_preamble,
51 UserPostamble => $user_postamble
52);
53
54my $parser = Pod::LaTeX->new(%params);
55ok($parser);
56
57# Create an output file
58open(OUTFH, "> test.tex" ) or die "Unable to open test tex file: $!\n";
59
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);
63
64close(OUTFH) or die "Error closing OUTFH test.tex: $!\n";
65
66# Now read in OUTFH and compare
67open(INFH, "< test.tex") or die "Unable to read test tex file: $!\n";
68my @output = <INFH>;
69
70ok(@output, @reference);
71
72for my $i (0..$#reference) {
73 next if $reference[$i] =~ /^%%/; # skip timestamp comments
74 ok($output[$i], $reference[$i]);
75}
76
77close(INFH) or die "Error closing INFH test.tex: $!\n";
78
79
80__DATA__
81
82\documentclass{article}
83
84\begin{document}
85
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
89
90%% Preamble supplied by user.
91
92\section{POD\label{POD}\index{POD}}
93
94
95This is a POD file, very simple. \textit{Bye}.
96
97\end{document}
98
99=pod
100
101=head1 POD
102
103This is a POD file, very simple. I<Bye>.
104