diff options
Diffstat (limited to 'lib/Pod/t')
-rw-r--r-- | lib/Pod/t/basic.cap | 9 | ||||
-rw-r--r-- | lib/Pod/t/basic.clr | 9 | ||||
-rw-r--r-- | lib/Pod/t/basic.man | 20 | ||||
-rw-r--r-- | lib/Pod/t/basic.ovr | 9 | ||||
-rw-r--r-- | lib/Pod/t/basic.pod | 10 | ||||
-rw-r--r-- | lib/Pod/t/basic.txt | 9 | ||||
-rw-r--r-- | lib/Pod/t/man.t | 86 | ||||
-rw-r--r-- | lib/Pod/t/text-errors.t | 81 |
8 files changed, 231 insertions, 2 deletions
diff --git a/lib/Pod/t/basic.cap b/lib/Pod/t/basic.cap index 21f38baa2f..d8f1ae2ec5 100644 --- a/lib/Pod/t/basic.cap +++ b/lib/Pod/t/basic.cap @@ -281,3 +281,12 @@ the text since otherwise text with mixed tabs and spaces will get messed up.) + And now we test verbatim paragraphs right before a heading. Older + versions of Pod::Man generated two spaces between paragraphs like this + and the heading. (In order to properly test this, one may have to + visually inspect the nroff output when run on the generated *roff + text, unfortunately.) + +[1mCONCLUSION[m + That's all, folks! + diff --git a/lib/Pod/t/basic.clr b/lib/Pod/t/basic.clr index b9d1cad717..acda09c8fa 100644 --- a/lib/Pod/t/basic.clr +++ b/lib/Pod/t/basic.clr @@ -282,3 +282,12 @@ the text since otherwise text with mixed tabs and spaces will get messed up.) + And now we test verbatim paragraphs right before a heading. Older + versions of Pod::Man generated two spaces between paragraphs like this + and the heading. (In order to properly test this, one may have to + visually inspect the nroff output when run on the generated *roff + text, unfortunately.) + +[1mCONCLUSION[0m + That's all, folks! + diff --git a/lib/Pod/t/basic.man b/lib/Pod/t/basic.man index 68434f3a23..c5d8c14f89 100644 --- a/lib/Pod/t/basic.man +++ b/lib/Pod/t/basic.man @@ -1,6 +1,5 @@ -.UC .SH "NAME" -basic.pod \- Test of various basic \s-1POD\s0 features in translators. +basic.pod \- Test of various basic POD features in translators. .SH "HEADINGS" .IX Header "HEADINGS" Try a few different levels of headings, with embedded formatting codes and @@ -299,10 +298,12 @@ Throw in a few verbatim paragraphs. \& print "This text is normal.\en"; \& print colored ['yellow on_magenta'], "Yellow on magenta.\en"; .Ve +.PP .Vb 2 \& use Term::ANSIColor qw(uncolor); \& print uncolor '01;31', "\en"; .Ve +.PP But this isn't verbatim (make sure it wraps properly), and the next paragraph is again: .PP @@ -310,9 +311,11 @@ paragraph is again: \& use Term::ANSIColor qw(:constants); \& print BOLD, BLUE, "This text is in bold blue.\en", RESET; .Ve +.PP .Vb 1 \& use Term::ANSIColor qw(:constants); $Term::ANSIColor::AUTORESET = 1; print BOLD BLUE "This text is in bold blue.\en"; print "This text is normal.\en"; .Ve +.PP (Ugh, that's obnoxiously long.) Try different spacing: .PP .Vb 7 @@ -324,12 +327,25 @@ paragraph is again: \&tab. But this should still be verbatim. \& As should this. .Ve +.PP This isn't. .PP .Vb 2 \& This is. And this: is an internal tab. It should be: \& |--| <= lined up with that. .Ve +.PP (Tricky, but tabs should be expanded before the translator starts in on the text since otherwise text with mixed tabs and spaces will get messed up.) +.PP +.Vb 5 +\& And now we test verbatim paragraphs right before a heading. Older +\& versions of Pod::Man generated two spaces between paragraphs like this +\& and the heading. (In order to properly test this, one may have to +\& visually inspect the nroff output when run on the generated *roff +\& text, unfortunately.) +.Ve +.SH "CONCLUSION" +.IX Header "CONCLUSION" +That's all, folks! diff --git a/lib/Pod/t/basic.ovr b/lib/Pod/t/basic.ovr index b20ca084d5..d762930e2e 100644 --- a/lib/Pod/t/basic.ovr +++ b/lib/Pod/t/basic.ovr @@ -282,3 +282,12 @@ VVEERRBBAATTIIMM the text since otherwise text with mixed tabs and spaces will get messed up.) + And now we test verbatim paragraphs right before a heading. Older + versions of Pod::Man generated two spaces between paragraphs like this + and the heading. (In order to properly test this, one may have to + visually inspect the nroff output when run on the generated *roff + text, unfortunately.) + +CCOONNCCLLUUSSIIOONN + That's all, folks! + diff --git a/lib/Pod/t/basic.pod b/lib/Pod/t/basic.pod index de76060ca1..03e2a2233b 100644 --- a/lib/Pod/t/basic.pod +++ b/lib/Pod/t/basic.pod @@ -404,4 +404,14 @@ This isn't. the text since otherwise text with mixed tabs and spaces will get messed up.) + And now we test verbatim paragraphs right before a heading. Older + versions of Pod::Man generated two spaces between paragraphs like this + and the heading. (In order to properly test this, one may have to + visually inspect the nroff output when run on the generated *roff + text, unfortunately.) + +=head1 CONCLUSION + +That's all, folks! + =cut diff --git a/lib/Pod/t/basic.txt b/lib/Pod/t/basic.txt index 8052215eeb..f2fae9d176 100644 --- a/lib/Pod/t/basic.txt +++ b/lib/Pod/t/basic.txt @@ -282,3 +282,12 @@ VERBATIM the text since otherwise text with mixed tabs and spaces will get messed up.) + And now we test verbatim paragraphs right before a heading. Older + versions of Pod::Man generated two spaces between paragraphs like this + and the heading. (In order to properly test this, one may have to + visually inspect the nroff output when run on the generated *roff + text, unfortunately.) + +CONCLUSION + That's all, folks! + diff --git a/lib/Pod/t/man.t b/lib/Pod/t/man.t new file mode 100644 index 0000000000..5171cc6d13 --- /dev/null +++ b/lib/Pod/t/man.t @@ -0,0 +1,86 @@ +#!/usr/bin/perl -w +# $Id: man.t,v 1.1 2002/01/02 09:03:28 eagle Exp $ +# +# man.t -- Additional specialized tests for Pod::Man. +# +# Copyright 2002 by Russ Allbery <rra@stanford.edu> +# +# This program is free software; you may redistribute it and/or modify it +# under the same terms as Perl itself. + +BEGIN { + chdir 't' if -d 't'; + if ($ENV{PERL_CORE}) { + @INC = '../lib'; + } else { + unshift (@INC, '../blib/lib'); + } + unshift (@INC, '../blib/lib'); + $| = 1; + print "1..2\n"; +} + +END { + print "not ok 1\n" unless $loaded; +} + +use Pod::Man; + +$loaded = 1; +print "ok 1\n"; + +my $n = 2; +while (<DATA>) { + next until $_ eq "###\n"; + open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n"; + while (<DATA>) { + last if $_ eq "###\n"; + print TMP $_; + } + close TMP; + my $parser = Pod::Man->new or die "Cannot create parser\n"; + $parser->parse_from_file ('tmp.pod', 'out.tmp'); + open (TMP, 'out.tmp') or die "Cannot open out.tmp: $!\n"; + while (<TMP>) { last if /^\.TH/ } + my $output; + { + local $/; + $output = <TMP>; + } + close TMP; + unlink ('tmp.pod', 'out.tmp'); + my $expected = ''; + while (<DATA>) { + last if $_ eq "###\n"; + $expected .= $_; + } + if ($output eq $expected) { + print "ok $n\n"; + } else { + print "not ok $n\n"; + print "Expected\n========\n$expected\nOutput\n======\n$output\n"; + } + $n++; +} + +# Below the marker are bits of POD and corresponding expected nroff output. +# This is used to test specific features or problems with Pod::Man. The input +# and output are separated by lines containing only ###. + +__DATA__ + +### +=head1 NAME + +gcc - GNU project C and C++ compiler + +=head1 C++ NOTES + +Other mentions of C++. +### +.SH "NAME" +gcc \- GNU project C and C++ compiler +.SH "\*(C+ NOTES" +.IX Header " NOTES" +Other mentions of \*(C+. +### diff --git a/lib/Pod/t/text-errors.t b/lib/Pod/t/text-errors.t new file mode 100644 index 0000000000..48d6c39a7a --- /dev/null +++ b/lib/Pod/t/text-errors.t @@ -0,0 +1,81 @@ +#!/usr/bin/perl -w +# $Id: text-errors.t,v 1.1 2002/01/01 02:41:53 eagle Exp $ +# +# texterrs.t -- Error tests for Pod::Text. +# +# Copyright 2001 by Russ Allbery <rra@stanford.edu> +# +# This program is free software; you may redistribute it and/or modify it +# under the same terms as Perl itself. + +BEGIN { + chdir 't' if -d 't'; + if ($ENV{PERL_CORE}) { + @INC = '../lib'; + } else { + unshift (@INC, '../blib/lib'); + } + unshift (@INC, '../blib/lib'); + $| = 1; + print "1..5\n"; +} + +END { + print "not ok 1\n" unless $loaded; +} + +use Pod::Text; + +$loaded = 1; +print "ok 1\n"; + +# Hard-code a few values to try to get reproducible results. +$ENV{COLUMNS} = 80; +$ENV{TERM} = 'xterm'; +$ENV{TERMCAP} = 'xterm:co=80:do=^J:md=\E[1m:us=\E[4m:me=\E[m'; + +# Set default options to match those of pod2man and pod2text. +my %options = (sentence => 0); + +# Capture warnings for inspection. +my $warnings = ''; +$SIG{__WARN__} = sub { $warnings .= $_[0] }; + +# Run a single test, given some POD to parse and the warning messages that are +# expected. Any formatted output is ignored; only warning messages are +# checked. Writes the POD to a temporary file since that's the easiest way to +# interact with Pod::Parser. +sub test_error { + my ($pod, $expected) = @_; + open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n"; + print TMP $pod; + close TMP; + my $parser = Pod::Text->new (%options); + return unless $parser; + $warnings = ''; + $parser->parse_from_file ('tmp.pod', 'out.tmp'); + unlink ('tmp.pod', 'out.tmp'); + if ($warnings eq $expected) { + return 1; + } else { + print " # '$warnings'\n # '$expected'\n"; + return 0; + } +} + +# The actual tests. +my @tests = ( + [ "=head1 a E<0x2028> b\n" + => "tmp.pod:1: Unknown escape: E<0x2028>\n" ], + [ "=head1 a Y<0x2028> b\n" + => "tmp.pod:1: Unknown formatting code: Y<0x2028>\n" ], + [ "=head1 TEST\n\n=command args\n" + => "tmp.pod:3: Unknown command paragraph: =command args\n" ], + [ "=head1 TEST\n\n Foo bar\n\n=back\n" + => "tmp.pod:5: Unmatched =back\n" ] +); +my $n = 2; +for (@tests) { + print (test_error ($$_[0], $$_[1]) ? "ok $n\n" : "not ok $n\n"); + $n++; +} |