From: Jarkko Hietaniemi Date: Tue, 20 Nov 2001 20:50:41 +0000 (+0000) Subject: Add test for Pod::LaTeX; re-sort MANIFEST. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=43c344fe72d16017dc10e89f633aa363dc10f20d;p=p5sagit%2Fp5-mst-13.2.git Add test for Pod::LaTeX; re-sort MANIFEST. p4raw-id: //depot/perl@13143 --- diff --git a/MANIFEST b/MANIFEST index 42e4ab2..f8b08d6 100644 --- a/MANIFEST +++ b/MANIFEST @@ -975,8 +975,8 @@ lib/filetest.t See if filetest works lib/Filter/Simple.pm Simple frontend to Filter::Util::Call lib/Filter/Simple/Changes Filter::Simple lib/Filter/Simple/README Filter::Simple -lib/Filter/Simple/t/filter.t See if Filter::Simple works lib/Filter/Simple/t/data.t See if Filter::Simple works +lib/Filter/Simple/t/filter.t See if Filter::Simple works lib/Filter/Simple/t/filter_only.t See if Filter::Simple works lib/find.pl A find emulator--used by find2perl lib/FindBin.pm Find name of currently executing program @@ -1153,6 +1153,7 @@ lib/Pod/Parser.pm Pod-Parser - define base class for parsing POD lib/Pod/ParseUtils.pm Pod-Parser - pod utility functions lib/Pod/Plainer.pm Pod migration utility module lib/Pod/Select.pm Pod-Parser - select portions of POD docs +lib/Pod/t/latex.t Test for Pod::LaTeX lib/Pod/Text.pm Pod-Parser - convert POD data to formatted ASCII text lib/Pod/Text/Color.pm Convert POD data to color ASCII text lib/Pod/Text/Overstrike.pm Convert POD data to formatted overstrike text @@ -1896,8 +1897,8 @@ pod/perltodo.pod Todo list explained pod/perltooc.pod Tom's object-oriented tutorial (more on class data) pod/perltoot.pod Tom's object-oriented tutorial pod/perltrap.pod Trap info -pod/perluniintro.pod Unicode introduction pod/perlunicode.pod Unicode support info +pod/perluniintro.pod Unicode introduction pod/perlutil.pod Accompanying utilities explained pod/perlvar.pod Variable info pod/perlxs.pod XS api info @@ -2050,8 +2051,8 @@ t/lib/dprof/test6_t Perl code profiler tests t/lib/dprof/test6_v Perl code profiler tests t/lib/dprof/V.pm Perl code profiler tests t/lib/filter-util.pl See if Filter::Util::Call works -t/lib/FilterTest.pm Helper file for lib/Filter/Simple/t/filter.t t/lib/FilterOnlyTest.pm Helper file for lib/Filter/Simple/t/filter_only.t +t/lib/FilterTest.pm Helper file for lib/Filter/Simple/t/filter.t t/lib/h2ph.h Test header file for h2ph t/lib/h2ph.pht Generated output from h2ph.h by h2ph, for comparison t/lib/locale/latin1 Part of locale.t in Latin 1 @@ -2275,15 +2276,15 @@ t/pod/testpods/lib/Pod/Stuff.pm Sample data for find.t t/README Instructions for regression tests t/run/exit.t Test perl's exit status. t/run/kill_perl.t Tests that kill perl. -t/run/runenv.t Test if perl honors its environment variables. t/run/noswitch.t Test aliasing ARGV for other switch tests +t/run/runenv.t Test if perl honors its environment variables. t/run/switcha.t Test the -a switch +t/run/switches.t Tests for the other switches +t/run/switchF.t Test the -F switch t/run/switchn.t Test the -n switch t/run/switchp.t Test the -p switch -t/run/switchx.t Test the -x switch t/run/switchx.aux Data for switchx.t -t/run/switchF.t Test the -F switch -t/run/switches.t Tests for the other switches +t/run/switchx.t Test the -x switch t/TEST The regression tester t/test.pl Simple testing library t/TestInit.pm Preamble library for core tests diff --git a/lib/Pod/t/latex.t b/lib/Pod/t/latex.t new file mode 100644 index 0000000..dd3323b --- /dev/null +++ b/lib/Pod/t/latex.t @@ -0,0 +1,349 @@ + +BEGIN { + chdir 't' if -d 't'; + @INC = '../lib'; + require Test; import Test; + plan(tests => 154); +} + +# Test that Pod::LaTeX works +# This test relies on the DATA filehandle +# DATA contains the latex that is used for comparison +# and the pod that was used to generate it. The two +# are separated by '=pod' +# Note that if the translator is adjusted the output tex +# will probably not match what is currently there. You +# will need to adjust it to match (assuming it is correct). + +use strict; + +use Pod::LaTeX; + +# Set up an END block to remove the test output file +END { unlink "test.tex" }; + +ok(1); + +# First thing to do is to read the expected output from +# the DATA filehandle and store it in a scalar. +# Do this until we read an =pod +my @reference; +while (my $line = ) { + last if $line =~ /^=pod/; + push(@reference,$line); +} + +# Create a new parser +my $parser = Pod::LaTeX->new; +ok($parser); +$parser->Head1Level(1); +# Add the preamble but remember not to compare the timestamps +$parser->AddPreamble(1); +$parser->AddPostamble(1); + +# For a laugh add a table of contents +$parser->TableOfContents(1); + +# Create an output file +open(OUTFH, "> test.tex" ) or die "Unable to open test tex file: $!\n"; + +# Read from the DATA filehandle and write to a new output file +# Really want to write this to a scalar +$parser->parse_from_filehandle(\*DATA,\*OUTFH); + +close(OUTFH) or die "Error closing OUTFH test.tex: $!\n"; + +# Now read in OUTFH and compare +open(INFH, "< test.tex") or die "Unable to read test tex file: $!\n"; +my @output = ; + +ok(@output, @reference); +for my $i (0..$#reference) { + next if $reference[$i] =~ /^%%/; # skip timestamp comments + ok($output[$i], $reference[$i]); +} + +close(INFH) or die "Error closing INFH test.tex: $!\n"; + + +__DATA__ +\documentclass{article} + +%% Latex generated from POD in document ... +%% Using the perl module Pod::LaTeX +%% Converted on Tue Nov 20 20:43:05 2001 + + +\usepackage{makeidx} +\makeindex + + +\begin{document} + +\tableofcontents + +\section{Introduction\label{Introduction}\index{Introduction}} +\begin{itemize} + +\item + +Always check the return codes of system calls. Good error messages should +go to STDERR, include which program caused the problem, what the failed +system call and arguments were, and (\textbf{very important}) should contain +the standard system error message for what went wrong. Here's a simple +but sufficient example: + +\begin{verbatim} + opendir(D, $dir) or die "can't opendir $dir: $!"; +\end{verbatim} + +\item + +Line up your transliterations when it makes sense: + +\begin{verbatim} + tr [abc] + [xyz]; +\end{verbatim} + + +The above should be aligned since it includes an embedded tab. + + +\item + +Think about reusability. Why waste brainpower on a one-shot when you +might want to do something like it again? Consider generalizing your +code. Consider writing a module or object class. Consider making your +code run cleanly with \texttt{use strict} and \texttt{-w} (or \texttt{use warnings} in +Perl 5.6) in effect. Consider giving away your code. Consider changing +your whole world view. Consider... oh, never mind. + + +\item + +Be consistent. + + +\item + +Be nice. + +\end{itemize} +\section{Links\label{Links}\index{Links}} + + +This link should just include one word: \textsf{Pod::LaTeX} + + + +This link should include the text \texttt{test} even though +it refers to \texttt{Pod::LaTeX}: \textsf{test}. + + + +Standard link: the \emph{Pod::LaTeX} manpage. + + + +Now refer to an external section: the section on \textsf{sec} in the \emph{Pod::LaTeX} manpage + +\section{Lists\label{Lists}\index{Lists}} + + +Test description list with long lines + +\begin{description} + +\item[Some short text] \mbox{} + +Some additional para. + +\begin{itemize} + +\item + +Nested itemized list + + +\item + +Second item + +\end{itemize} + +\item[some longer text than that] \mbox{} + +and again. + + +\item[this text is even longer and greater than] \textbf{40 characters} + +Some more content for the item. + + +\item[this is some text with \textit{something across}] \textbf{the 40 char boundary} + +This is item content. + +\end{description} +\section{Escapes\label{Escapes}\index{Escapes}} + + +Test some normal escapes such as $<$ (lt) and $>$ (gt) and $|$ (verbar) and +\texttt{\~{}} (tilde) and \& (amp) as well as $<$ (Esc lt) and $|$ (Esc +verbar) and / (Esc sol) and $>$ (Esc gt) and \& (Esc amp) +and " (Esc quot) and even $\alpha$ (Esc alpha). + +\section{For blocks\label{For_blocks}\index{For blocks}} + Some latex code \textbf{here}. + + + +Some text that should appear. + + + +Some more text that should appear + +Some latex in a \textsf{begin block} + +and some more + +\begin{equation} +a = \frac{3}{2} +\end{equation} + + + +Back to pod. + +\printindex + +\end{document} +=pod + +=head1 Introduction + +=over 4 + +=item * + +Always check the return codes of system calls. Good error messages should +go to STDERR, include which program caused the problem, what the failed +system call and arguments were, and (B) should contain +the standard system error message for what went wrong. Here's a simple +but sufficient example: + + opendir(D, $dir) or die "can't opendir $dir: $!"; + +=item * + +Line up your transliterations when it makes sense: + + tr [abc] + [xyz]; + +The above should be aligned since it includes an embedded tab. + +=item * + +Think about reusability. Why waste brainpower on a one-shot when you +might want to do something like it again? Consider generalizing your +code. Consider writing a module or object class. Consider making your +code run cleanly with C and C<-w> (or C in +Perl 5.6) in effect. Consider giving away your code. Consider changing +your whole world view. Consider... oh, never mind. + +=item * + +Be consistent. + +=item * + +Be nice. + +=back + +=head1 Links + +This link should just include one word: L + +This link should include the text C even though +it refers to C: L. + +Standard link: L. + +Now refer to an external section: L + + +=head1 Lists + +Test description list with long lines + +=over 4 + +=item Some short text + +Some additional para. + +=over 4 + +=item * + +Nested itemized list + +=item * + +Second item + +=back + +=item some longer text than that + +and again. + +=item this text is even longer and greater than 40 characters + +Some more content for the item. + +=item this is some text with I the 40 char boundary + +This is item content. + +=back + +=head1 Escapes + +Test some normal escapes such as < (lt) and > (gt) and | (verbar) and +~ (tilde) and & (amp) as well as E (Esc lt) and E (Esc +verbar) and E (Esc sol) and E (Esc gt) and E (Esc amp) +and E (Esc quot) and even E (Esc alpha). + +=head1 For blocks + +=for latex + Some latex code \textbf{here}. + +Some text that should appear. + +=for comment + Should not print anything + +Some more text that should appear + +=begin latex + +Some latex in a \textsf{begin block} + +and some more + +\begin{equation} +a = \frac{3}{2} +\end{equation} + +=end latex + +Back to pod. + +=cut