cpan/podlators/t/basic.t podlators test
cpan/podlators/t/basic.txt podlators test
cpan/podlators/t/color.t podlators test
+cpan/podlators/t/devise-date.t podlators test
cpan/podlators/t/filehandle.t podlators test
+cpan/podlators/t/man-heading.t podlators test
cpan/podlators/t/man-options.t podlators test
cpan/podlators/t/man.t podlators test
cpan/podlators/t/man-utf8.t podlators test
+cpan/podlators/t/overstrike.t podlators test
cpan/podlators/t/parselink.t podlators test
cpan/podlators/t/pod-parser.t podlators test
cpan/podlators/t/pod-spelling.t podlators test
'podlators' =>
{
'MAINTAINER' => 'rra',
- 'DISTRIBUTION' => 'RRA/podlators-2.2.2.tar.gz',
+ 'DISTRIBUTION' => 'RRA/podlators-2.3.0.tar.gz',
'FILES' => q[cpan/podlators
pod/pod2man.PL
pod/pod2text.PL
-$VERSION = '2.2.2';
+$VERSION = '2.3.0';
use Carp qw(croak);
use Pod::Simple ();
-use POSIX qw(strftime);
@ISA = qw(Pod::Simple);
-$VERSION = '2.22';
+$VERSION = '2.23';
# Set the debugging level. If someone has inserted a debug function into this
# class already, use that. Otherwise, use any Pod::Simple debug function
# If we have a command handler, we need to accumulate the contents of the
# tag before calling it. Turn off IN_NAME for any command other than
- # <Para> so that IN_NAME isn't still set for the first heading after the
- # NAME heading.
+ # <Para> and the formatting codes so that IN_NAME isn't still set for the
+ # first heading after the NAME heading.
if ($self->can ("cmd_$method")) {
DEBUG > 2 and print "<$element> starts saving a tag\n";
- $$self{IN_NAME} = 0 if ($element ne 'Para');
+ $$self{IN_NAME} = 0 if ($element ne 'Para' && length ($element) > 1);
# How we're going to format embedded text blocks depends on the tag
# and also depends on our parent tags. Thankfully, inside tags that
# several places in the following regex.
my $index = '(?: \[.*\] | \{.*\} )?';
+ # If in NAME section, just return an ASCII quoted string to avoid
+ # confusing tools like whatis.
+ return qq{"$_"} if $$self{IN_NAME};
+
# Check for things that we don't want to quote, and if we find any of
# them, return the string with just a font change and no quoting.
m{
for (@output) {
my ($type, $entry) = @$_;
$entry =~ s/\"/\"\"/g;
+ $entry =~ s/\\/\\\\/g;
$self->output (".IX $type " . '"' . $entry . '"' . "\n");
}
}
} else {
$time = time;
}
- return strftime ('%Y-%m-%d', localtime $time);
+
+ # Can't use POSIX::strftime(), which uses Fcntl, because MakeMaker
+ # uses this and it has to work in the core which can't load dynamic
+ # libraries.
+ my ($year, $month, $day) = (localtime $time)[5,4,3];
+ return sprintf ("%04d-%02d-%02d", $year + 1900, $month + 1, $day);
}
# Print out the preamble and the title. The meaning of the arguments to .TH
# All of the formatting codes that aren't handled internally by the parser,
# other than L<> and X<>.
-sub cmd_b { return '\f(BS' . $_[2] . '\f(BE' }
-sub cmd_i { return '\f(IS' . $_[2] . '\f(IE' }
-sub cmd_f { return '\f(IS' . $_[2] . '\f(IE' }
+sub cmd_b { return $_[0]->{IN_NAME} ? $_[2] : '\f(BS' . $_[2] . '\f(BE' }
+sub cmd_i { return $_[0]->{IN_NAME} ? $_[2] : '\f(IS' . $_[2] . '\f(IE' }
+sub cmd_f { return $_[0]->{IN_NAME} ? $_[2] : '\f(IS' . $_[2] . '\f(IE' }
sub cmd_c { return $_[0]->quote_literal ($_[2]) }
# Index entries are just added to the pending entries.
# a URL.
sub cmd_l {
my ($self, $attrs, $text) = @_;
- return $$attrs{type} eq 'url' ? "<$text>" : $text;
+ if ($$attrs{type} eq 'url') {
+ if (not defined($$attrs{to}) or $$attrs{to} eq $text) {
+ return "<$text>";
+ } else {
+ return "$text <$$attrs{to}>";
+ }
+ } else {
+ return $text;
+ }
}
##############################################################################
# Pod::ParseLink -- Parse an L<> formatting code in POD text.
#
-# Copyright 2001, 2008 by Russ Allbery <rra@stanford.edu>
+# Copyright 2001, 2008, 2009 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.
@ISA = qw(Exporter);
@EXPORT = qw(parselink);
-$VERSION = '1.09';
+$VERSION = '1.10';
##############################################################################
# Implementation
sub parselink {
my ($link) = @_;
$link =~ s/\s+/ /g;
+ my $text;
+ if ($link =~ /\|/) {
+ ($text, $link) = split (/\|/, $link, 2);
+ }
if ($link =~ /\A\w+:[^:\s]\S*\Z/) {
- return (undef, $link, $link, undef, 'url');
- } else {
- my $text;
- if ($link =~ /\|/) {
- ($text, $link) = split (/\|/, $link, 2);
+ my $inferred;
+ if (defined ($text) && length ($text) > 0) {
+ return ($text, $text, $link, undef, 'url');
+ } else {
+ return ($text, $link, $link, undef, 'url');
}
+ } else {
my ($name, $section) = _parse_section ($link);
- my $inferred = $text || _infer_text ($name, $section);
+ my $inferred;
+ if (defined ($text) && length ($text) > 0) {
+ $inferred = $text;
+ } else {
+ $inferred = _infer_text ($name, $section);
+ }
my $type = ($name && $name =~ /\(\S*\)/) ? 'man' : 'pod';
return ($text, $inferred, $name, $section, $type);
}
=head1 COPYRIGHT AND LICENSE
-Copyright 2001, 2008 Russ Allbery <rra@stanford.edu>.
+Copyright 2001, 2008, 2009 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.
# Pod::Text -- Convert POD data to formatted ASCII text.
#
-# Copyright 1999, 2000, 2001, 2002, 2004, 2006, 2008
+# Copyright 1999, 2000, 2001, 2002, 2004, 2006, 2008, 2009
# Russ Allbery <rra@stanford.edu>
#
# This program is free software; you may redistribute it and/or modify it
# We have to export pod2text for backward compatibility.
@EXPORT = qw(pod2text);
-$VERSION = '3.13';
+$VERSION = '3.14';
##############################################################################
# Initialization
# Text blocks
##############################################################################
+# Intended for subclasses to override, this method returns text with any
+# non-printing formatting codes stripped out so that length() correctly
+# returns the length of the text. For basic Pod::Text, it does nothing.
+sub strip_format {
+ my ($self, $string) = @_;
+ return $string;
+}
+
# This method is called whenever an =item command is complete (in other words,
# we've seen its associated paragraph or know for certain that it doesn't have
# one). It gets the paragraph associated with the item as an argument. If
my $indent = $$self{INDENTS}[-1];
$indent = $$self{opt_indent} unless defined $indent;
my $margin = ' ' x $$self{opt_margin};
- my $fits = ($$self{MARGIN} - $indent >= length ($tag) + 1);
+ my $tag_length = length ($self->strip_format ($tag));
+ my $fits = ($$self{MARGIN} - $indent >= $tag_length + 1);
# If the tag doesn't fit, or if we have no associated text, print out the
# tag separately. Otherwise, put the tag in the margin of the paragraph.
$space =~ s/^$margin /$margin:/ if $$self{opt_alt};
$text = $self->reformat ($text);
$text =~ s/^$margin /$margin:/ if ($$self{opt_alt} && $indent > 0);
- my $tagspace = ' ' x length $tag;
+ my $tagspace = ' ' x $tag_length;
$text =~ s/^($space)$tagspace/$1$tag/ or warn "Bizarre space in item";
$self->output ($text);
}
# a URL.
sub cmd_l {
my ($self, $attrs, $text) = @_;
- return $$attrs{type} eq 'url' ? "<$text>" : $text;
+ if ($$attrs{type} eq 'url') {
+ if (not defined($$attrs{to}) or $$attrs{to} eq $text) {
+ return "<$text>";
+ } else {
+ return "$text <$$attrs{to}>";
+ }
+ } else {
+ return $text;
+ }
}
##############################################################################
=head1 COPYRIGHT AND LICENSE
-Copyright 1999, 2000, 2001, 2002, 2004, 2006, 2008 Russ Allbery
+Copyright 1999, 2000, 2001, 2002, 2004, 2006, 2008, 2009 Russ Allbery
<rra@stanford.edu>.
This program is free software; you may redistribute it and/or modify it
# Pod::Text::Color -- Convert POD data to formatted color ASCII text
#
-# Copyright 1999, 2001, 2004, 2006, 2008 Russ Allbery <rra@stanford.edu>
+# Copyright 1999, 2001, 2004, 2006, 2008, 2009 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.
$self->output ($code);
}
+# Strip all of the formatting from a provided string, returning the stripped
+# version. We will eventually want to use colorstrip() from Term::ANSIColor,
+# but it's fairly new so avoid the tight dependency.
+sub strip_format {
+ my ($self, $text) = @_;
+ $text =~ s/\e\[[\d;]*m//g;
+ return $text;
+}
+
# We unfortunately have to override the wrapping code here, since the normal
# wrapping code gets really confused by all the escape sequences.
sub wrap {
=head1 COPYRIGHT AND LICENSE
-Copyright 1999, 2001, 2004, 2006, 2008 Russ Allbery <rra@stanford.edu>.
+Copyright 1999, 2001, 2004, 2006, 2008, 2009 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.
@ISA = qw(Pod::Text);
-$VERSION = '2.03';
+$VERSION = '2.04';
##############################################################################
# Overrides
$self->output ($code);
}
+# Strip all of the formatting from a provided string, returning the stripped
+# version.
+sub strip_format {
+ my ($self, $text) = @_;
+ $text =~ s/(.)[\b]\1/$1/g;
+ $text =~ s/_[\b]//g;
+ return $text;
+}
+
# We unfortunately have to override the wrapping code here, since the normal
# wrapping code gets really confused by all the backspaces.
sub wrap {
}
##############################################################################
-# Utility functions
-##############################################################################
-
-# Strip all of the formatting from a provided string, returning the stripped
-# version.
-sub strip_format {
- my ($self, $text) = @_;
- $text =~ s/(.)[\b]\1/$1/g;
- $text =~ s/_[\b]//g;
- return $text;
-}
-
-##############################################################################
# Module return value and documentation
##############################################################################
=head1 COPYRIGHT AND LICENSE
Copyright 2000 by Joe Smith <Joe.Smith@inwap.com>.
-Copyright 2001, 2004 by Russ Allbery <rra@stanford.edu>.
+Copyright 2001, 2004, 2008 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.
# Pod::Text::Termcap -- Convert POD data to ASCII text with format escapes.
#
-# Copyright 1999, 2001, 2002, 2004, 2006, 2008 Russ Allbery <rra@stanford.edu>
+# Copyright 1999, 2001, 2002, 2004, 2006, 2008, 2009
+# 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.
$self->output ($$self{BOLD} . $code . $$self{NORM});
}
+# Strip all of the formatting from a provided string, returning the stripped
+# version.
+sub strip_format {
+ my ($self, $text) = @_;
+ $text =~ s/\Q$$self{BOLD}//g;
+ $text =~ s/\Q$$self{UNDL}//g;
+ $text =~ s/\Q$$self{NORM}//g;
+ return $text;
+}
+
# Override the wrapping code to igore the special sequences.
sub wrap {
my $self = shift;
=head1 COPYRIGHT AND LICENSE
-Copyright 1999, 2001, 2002, 2004, 2006, 2008 Russ Allbery
+Copyright 1999, 2001, 2002, 2004, 2006, 2008, 2009 Russ Allbery
<rra@stanford.edu>.
This program is free software; you may redistribute it and/or modify it
#
# basic.t -- Basic tests for podlators.
#
-# Copyright 2001, 2002, 2004, 2006 by Russ Allbery <rra@stanford.edu>
+# Copyright 2001, 2002, 2004, 2006, 2009 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.
chdir 't' if -d 't';
if ($ENV{PERL_CORE}) {
@INC = '../lib';
- } else {
- unshift (@INC, '../blib/lib');
}
unshift (@INC, '../blib/lib');
$| = 1;
- print "1..11\n";
}
-END {
- print "not ok 1\n" unless $loaded;
-}
+use strict;
-use Pod::Man;
-use Pod::Text;
-use Pod::Text::Overstrike;
-use Pod::Text::Termcap;
+use Test::More tests => 15;
+
+BEGIN {
+ use_ok ('Pod::Man');
+ use_ok ('Pod::Text');
+ use_ok ('Pod::Text::Overstrike');
+ use_ok ('Pod::Text::Termcap');
+}
# Find the path to the test source files. This requires some fiddling when
# these tests are run as part of Perl core.
}
}
-$loaded = 1;
-print "ok 1\n";
-
# Hard-code a few values to try to get reproducible results.
$ENV{COLUMNS} = 80;
$ENV{TERM} = 'xterm';
'Pod::Text::Termcap' => 'cap');
# Set default options to match those of pod2man and pod2text.
-%options = (sentence => 0);
+our %options = (sentence => 0);
-my $n = 2;
-for (sort keys %translators) {
- if ($_ eq 'Pod::Text::Color') {
- eval { require Term::ANSIColor };
- if ($@) {
- print "ok $n # skip\n";
- $n++;
- print "ok $n # skip\n";
- $n++;
- next;
+for my $module (sort keys %translators) {
+ SKIP: {
+ if ($module eq 'Pod::Text::Color') {
+ eval { require Term::ANSIColor };
+ skip 'Term::ANSIColor not found', 3 if $@;
+ require_ok ('Pod::Text::Color');
}
- require Pod::Text::Color;
- }
- my $parser = $_->new (%options);
- print (($parser && ref ($parser) eq $_) ? "ok $n\n" : "not ok $n\n");
- $n++;
+ my $parser = $module->new (%options);
+ isa_ok ($parser, $module, 'Parser object');
- # For Pod::Man, strip out the autogenerated header up to the .TH title
- # line. That means that we don't check those things; oh well. The header
- # changes with each version change or touch of the input file.
- open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n";
- $parser->parse_from_file (source_path ('basic.pod'), \*OUT);
- close OUT;
- if ($_ eq 'Pod::Man') {
- open (TMP, 'out.tmp') or die "Cannot open out.tmp: $!\n";
- open (OUTPUT, "> out.$translators{$_}")
- or die "Cannot create out.$translators{$_}: $!\n";
- local $_;
- while (<TMP>) { last if /^\.nh/ }
- print OUTPUT while <TMP>;
- close OUTPUT;
- close TMP;
- unlink 'out.tmp';
- } else {
- rename ('out.tmp', "out.$translators{$_}")
- or die "Cannot rename out.tmp: $!\n";
- }
- {
- local $/;
- open (MASTER, source_path ("basic.$translators{$_}"))
- or die "Cannot open basic.$translators{$_}: $!\n";
- open (OUTPUT, "out.$translators{$_}")
- or die "Cannot open out.$translators{$_}: $!\n";
- my $master = <MASTER>;
- my $output = <OUTPUT>;
- close MASTER;
- close OUTPUT;
+ # For Pod::Man, strip out the autogenerated header up to the .TH title
+ # line. That means that we don't check those things; oh well. The
+ # header changes with each version change or touch of the input file.
+ open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n";
+ $parser->parse_from_file (source_path ('basic.pod'), \*OUT);
+ close OUT;
+ if ($module eq 'Pod::Man') {
+ open (TMP, 'out.tmp') or die "Cannot open out.tmp: $!\n";
+ open (OUTPUT, "> out.$translators{$module}")
+ or die "Cannot create out.$translators{$module}: $!\n";
+ local $_;
+ while (<TMP>) { last if /^\.nh/ }
+ print OUTPUT while <TMP>;
+ close OUTPUT;
+ close TMP;
+ 1 while unlink 'out.tmp';
+ } else {
+ rename ('out.tmp', "out.$translators{$module}")
+ or die "Cannot rename out.tmp: $!\n";
+ }
+
+ # Slurp the output and expected output and compare them.
+ my ($master, $output);
+ {
+ local $/;
+ open (MASTER, source_path ("basic.$translators{$module}"))
+ or die "Cannot open basic.$translators{$module}: $!\n";
+ open (OUTPUT, "out.$translators{$module}")
+ or die "Cannot open out.$translators{$module}: $!\n";
+ $master = <MASTER>;
+ $output = <OUTPUT>;
+ close MASTER;
+ close OUTPUT;
+ }
# OS/390 is EBCDIC, which uses a different character for ESC
# apparently. Try to convert so that the test still works.
- if ($^O eq 'os390' && $_ eq 'Pod::Text::Termcap') {
+ if ($^O eq 'os390' and $module eq 'Pod::Text::Termcap') {
$output =~ tr/\033/\047/;
}
-
- if ($master eq $output) {
- print "ok $n\n";
- unlink "out.$translators{$_}";
+ if (ok ($master eq $output, "$module output is correct")) {
+ 1 while unlink "out.$translators{$module}";
} else {
- print "not ok $n\n";
- print "# Non-matching output left in out.$translators{$_}\n";
+ diag ("Non-matching output left in out.$translators{$module}\n");
}
}
- $n++;
}
#
# color.t -- Additional specialized tests for Pod::Text::Color.
#
-# Copyright 2002, 2004, 2006 by Russ Allbery <rra@stanford.edu>
+# Copyright 2002, 2004, 2006, 2009 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.
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 strict;
+
+use Test::More;
+# Skip this test if Term::ANSIColor isn't available.
eval { require Term::ANSIColor };
if ($@) {
- for (1..2) {
- print "ok $_ # skip\n";
- }
- $loaded = 1;
- exit;
+ plan skip_all => 'Term::ANSIColor required for Pod::Text::Color';
+} else {
+ plan tests => 4;
}
-require Pod::Text::Color;
+require_ok ('Pod::Text::Color');
-$loaded = 1;
-print "ok 1\n";
-
-my $parser = Pod::Text::Color->new or die "Cannot create parser\n";
-my $n = 2;
+# Load tests from the data section below, write the POD to a temporary file,
+# convert it, and compare to the expected output.
+my $parser = Pod::Text::Color->new;
+isa_ok ($parser, 'Pod::Text::Color', 'Parser object');
+my $n = 1;
while (<DATA>) {
next until $_ eq "###\n";
open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n";
$output = <TMP>;
}
close TMP;
- unlink ('tmp.pod', 'out.tmp');
+ 1 while 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";
- }
+ is ($output, $expected, "Output correct for test $n");
$n++;
}
# Below the marker are bits of POD and corresponding expected output. This is
-# used to test specific features or problems with Pod::Text::Termcap. The
-# input and output are separated by lines containing only ###.
+# used to test specific features or problems with Pod::Text::Color. The input
+# and output are separated by lines containing only ###.
__DATA__
\e[1m\e[33mDo\e[0m\e[0m \e[33m\e[1mnot\e[0m\e[0m \e[1m\e[33minclude\e[0m\e[0m \e[1m\e[33mformatting codes when\e[0m\e[0m \e[1m\e[33mwrapping\e[0m\e[0m.
###
+
+###
+=head1 TAG WIDTH
+
+=over 10
+
+=item 12345678
+
+A
+
+=item B<12345678>
+
+B
+
+=item 1
+
+C
+
+=item B<1>
+
+D
+
+=back
+###
+\e[1mTAG WIDTH\e[0m
+ 12345678 A
+
+ \e[1m12345678\e[0m B
+
+ 1 C
+
+ \e[1m1\e[0m D
+
+###
--- /dev/null
+#!/usr/bin/perl -w
+
+# In order for MakeMaker to build in the core, nothing can use
+# Fcntl which includes POSIX. devise_date()'s use of strftime()
+# was replaced. This tests that it's identical.
+
+use strict;
+
+use Test::More tests => 1;
+
+use Pod::Man;
+use POSIX qw(strftime);
+
+my $parser = Pod::Man->new;
+is $parser->devise_date, strftime("%Y-%m-%d", localtime);
#
# filehandle.t -- Test the parse_from_filehandle interface.
#
-# Copyright 2006 by Russ Allbery <rra@stanford.edu>
+# Copyright 2006, 2009 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.
chdir 't' if -d 't';
if ($ENV{PERL_CORE}) {
@INC = '../lib';
- } else {
- unshift (@INC, '../blib/lib');
}
unshift (@INC, '../blib/lib');
$| = 1;
- print "1..3\n";
}
-END {
- print "not ok 1\n" unless $loaded;
-}
+use strict;
-use Pod::Man;
-use Pod::Text;
+use Test::More tests => 6;
-$loaded = 1;
-print "ok 1\n";
+BEGIN {
+ use_ok ('Pod::Man');
+ use_ok ('Pod::Text');
+}
-my $man = Pod::Man->new or die "Cannot create parser\n";
-my $text = Pod::Text->new or die "Cannot create parser\n";
-my $n = 2;
+my $man = Pod::Man->new;
+isa_ok ($man, 'Pod::Man', 'Pod::Man parser object');
+my $text = Pod::Text->new;
+isa_ok ($text, 'Pod::Text', 'Pod::Text parser object');
while (<DATA>) {
next until $_ eq "###\n";
open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n";
print TMP $_;
}
close TMP;
+
+ # Test Pod::Man output.
open (IN, '< tmp.pod') or die "Cannot open tmp.pod: $!\n";
open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n";
$man->parse_from_filehandle (\*IN, \*OUT);
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++;
+ is ($output, $expected, 'Pod::Man output is correct');
+
+ # Test Pod::Text output.
open (IN, '< tmp.pod') or die "Cannot open tmp.pod: $!\n";
open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n";
$text->parse_from_filehandle (\*IN, \*OUT);
$output = <OUT>;
}
close OUT;
- unlink ('tmp.pod', 'out.tmp');
+ 1 while unlink ('tmp.pod', 'out.tmp');
$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++;
+ is ($output, $expected, 'Pod::Text output is correct');
}
# Below the marker are bits of POD, corresponding expected nroff output, and
--- /dev/null
+#!/usr/bin/perl -w
+#
+# man-options.t -- Additional tests for Pod::Man options.
+#
+# Copyright 2002, 2004, 2006, 2008, 2009 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';
+ }
+ unshift (@INC, '../blib/lib');
+ $| = 1;
+}
+
+use strict;
+
+use Test::More tests => 7;
+BEGIN { use_ok ('Pod::Man') }
+
+my $n = 1;
+while (<DATA>) {
+ my %options;
+ next until $_ eq "###\n";
+ while (<DATA>) {
+ last if $_ eq "###\n";
+ my ($option, $value) = split (' ', $_, 2);
+ chomp $value;
+ $options{$option} = $value;
+ }
+ open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n";
+ print TMP "=head1 NAME\n\ntest - Test man page\n";
+ close TMP;
+ my $parser = Pod::Man->new (%options);
+ isa_ok ($parser, 'Pod::Man', 'Parser object');
+ open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n";
+ $parser->parse_from_file ('tmp.pod', \*OUT);
+ close OUT;
+ open (TMP, 'out.tmp') or die "Cannot open out.tmp: $!\n";
+ my $heading;
+ while (<TMP>) {
+ if (/^\.TH/) {
+ $heading = $_;
+ last;
+ }
+ }
+ close TMP;
+ unlink ('tmp.pod', 'out.tmp');
+ my $expected = '';
+ while (<DATA>) {
+ last if $_ eq "###\n";
+ $expected .= $_;
+ }
+ is ($heading, $expected, "Heading is correct for test $n");
+ $n++;
+}
+
+# Below the marker are sets of options and the corresponding expected .TH line
+# from the man page. This is used to test specific features or problems with
+# Pod::Man. The options and output are separated by lines containing only
+# ###.
+
+__DATA__
+
+###
+date 2009-01-17
+release 1.0
+###
+.TH TMP 1 "2009-01-17" "1.0" "User Contributed Perl Documentation"
+###
+
+###
+date 2009-01-17
+name TEST
+section 8
+release 2.0-beta
+###
+.TH TEST 8 "2009-01-17" "2.0-beta" "User Contributed Perl Documentation"
+###
+
+###
+date 2009-01-17
+release 1.0
+center Testing Documentation
+###
+.TH TMP 1 "2009-01-17" "1.0" "Testing Documentation"
+###
#
# man-options.t -- Additional tests for Pod::Man options.
#
-# Copyright 2002, 2004, 2006, 2008 Russ Allbery <rra@stanford.edu>
+# Copyright 2002, 2004, 2006, 2008, 2009 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.
chdir 't' if -d 't';
if ($ENV{PERL_CORE}) {
@INC = '../lib';
- } else {
- unshift (@INC, '../blib/lib');
}
unshift (@INC, '../blib/lib');
$| = 1;
- print "1..7\n";
}
-END {
- print "not ok 1\n" unless $loaded;
-}
+use strict;
-use Pod::Man;
+use Test::More tests => 10;
+BEGIN { use_ok ('Pod::Man') }
# Redirect stderr to a file.
sub stderr_save {
close OLDERR;
}
-$loaded = 1;
-print "ok 1\n";
-
-my $n = 2;
+my $n = 1;
while (<DATA>) {
my %options;
next until $_ eq "###\n";
print TMP $_;
}
close TMP;
- my $parser = Pod::Man->new (%options) or die "Cannot create parser\n";
+ my $parser = Pod::Man->new (%options);
+ isa_ok ($parser, 'Pod::Man', 'Parser object');
open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n";
stderr_save;
$parser->parse_from_file ('tmp.pod', \*OUT);
$output = <TMP>;
}
close TMP;
- unlink ('tmp.pod', 'out.tmp');
+ 1 while 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++;
+ is ($output, $expected, "Output correct for test $n");
open (ERR, 'out.err') or die "Cannot open out.err: $!\n";
my $errors;
{
$errors = <ERR>;
}
close ERR;
- unlink ('out.err');
+ 1 while unlink ('out.err');
$expected = '';
while (<DATA>) {
last if $_ eq "###\n";
$expected .= $_;
}
- if ($errors eq $expected) {
- print "ok $n\n";
- } else {
- print "not ok $n\n";
- print "Expected errors:\n ${expected}Errors:\n $errors";
- }
+ is ($errors, $expected, "Errors are correct for test $n");
$n++;
}
-# Below the marker are bits of POD and corresponding expected text output.
-# This is used to test specific features or problems with Pod::Man. The
-# input and output are separated by lines containing only ###.
+# Below the marker are bits of POD and corresponding expected text output and
+# error output. This is used to test specific features or problems with
+# Pod::Man. The options, input, output, and errors are separated by lines
+# containing only ###.
__DATA__
#
# man-options.t -- Additional tests for Pod::Man options.
#
-# Copyright 2002, 2004, 2006, 2008 Russ Allbery <rra@stanford.edu>
+# Copyright 2002, 2004, 2006, 2008, 2009 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.
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";
-
- # UTF-8 support requires Perl 5.8 or later.
- if ($] < 5.008) {
- my $n;
- for $n (1..5) {
- print "ok $n # skip -- Perl 5.8 required for UTF-8 support\n";
- }
- exit;
- }
}
-END {
- print "not ok 1\n" unless $loaded;
-}
+use strict;
-use Pod::Man;
+use Test::More;
-$loaded = 1;
-print "ok 1\n";
+# UTF-8 support requires Perl 5.8 or later.
+BEGIN {
+ if ($] < 5.008) {
+ plan skip_all => 'Perl 5.8 required for UTF-8 support';
+ } else {
+ plan tests => 7;
+ }
+}
+BEGIN { use_ok ('Pod::Man') }
-my $n = 2;
+# Force UTF-8 on all relevant file handles. Do this inside eval in case the
+# encoding parameter doesn't work.
eval { binmode (\*DATA, ':encoding(utf-8)') };
eval { binmode (\*STDOUT, ':encoding(utf-8)') };
+my $builder = Test::More->builder;
+eval { binmode ($builder->output, ':encoding(utf-8)') };
+eval { binmode ($builder->failure_output, ':encoding(utf-8)') };
+
+my $n = 1;
while (<DATA>) {
my %options;
next until $_ eq "###\n";
print TMP $_;
}
close TMP;
- my $parser = Pod::Man->new (%options) or die "Cannot create parser\n";
+ my $parser = Pod::Man->new (%options);
+ isa_ok ($parser, 'Pod::Man', 'Parser object');
open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n";
$parser->parse_from_file ('tmp.pod', \*OUT);
close OUT;
$output = <TMP>;
}
close TMP;
- unlink ('tmp.pod', 'out.tmp');
- if (($options{utf8} && !$accents) || (!$options{utf8} && $accents)) {
- print "ok $n\n";
+ 1 while unlink ('tmp.pod', 'out.tmp');
+ if ($options{utf8}) {
+ ok (!$accents, "Saw no accent definitions for test $n");
} else {
- print "not ok $n\n";
- print ($accents ? "Saw accents\n" : "Saw no accents\n");
- print ($options{utf8} ? "Wanted no accents\n" : "Wanted accents\n");
+ ok ($accents, "Saw accent definitions for test $n");
}
- $n++;
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";
- }
+ is ($output, $expected, "Output correct for test $n");
$n++;
}
#
# man.t -- Additional specialized tests for Pod::Man.
#
-# Copyright 2002, 2003, 2004, 2006, 2007, 2008
+# Copyright 2002, 2003, 2004, 2006, 2007, 2008, 2009
# Russ Allbery <rra@stanford.edu>
#
# This program is free software; you may redistribute it and/or modify it
chdir 't' if -d 't';
if ($ENV{PERL_CORE}) {
@INC = '../lib';
- } else {
- unshift (@INC, '../blib/lib');
}
unshift (@INC, '../blib/lib');
$| = 1;
- print "1..25\n";
}
-END {
- print "not ok 1\n" unless $loaded;
-}
-
-use Pod::Man;
+use strict;
-$loaded = 1;
-print "ok 1\n";
+use Test::More tests => 30;
+BEGIN { use_ok ('Pod::Man') }
# Test whether we can use binmode to set encoding.
my $have_encoding = (eval { require PerlIO::encoding; 1 } and not $@);
-my $parser = Pod::Man->new or die "Cannot create parser\n";
-my $n = 2;
+my $parser = Pod::Man->new;
+isa_ok ($parser, 'Pod::Man', 'Parser object');
+my $n = 1;
while (<DATA>) {
next until $_ eq "###\n";
open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n";
$output = <OUT>;
}
close OUT;
- unlink ('tmp.pod', 'out.tmp');
+ 1 while 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";
- }
+ is ($output, $expected, "Output correct for test $n");
$n++;
}
###
=head1 NAME
-gcc - GNU project C and C++ compiler
+gcc - GNU project C<C> and C++ compiler
=head1 C++ NOTES
Other mentions of C++.
###
.SH "NAME"
-gcc \- GNU project C and C++ compiler
+gcc \- GNU project "C" and C++ compiler
.SH "\*(C+ NOTES"
.IX Header " NOTES"
Other mentions of \*(C+.
.PP
More text.
###
+
+###
+=head1 NAME
+
+test - C<test>
+###
+.SH "NAME"
+test \- "test"
+###
+
+###
+=head1 INDEX
+
+Index entry matching a whitespace escape.X<\n>
+###
+.SH "INDEX"
+.IX Header "INDEX"
+Index entry matching a whitespace escape.
+.IX Xref "\\n"
+###
+
+###
+=head1 LINK TO URL
+
+This is a L<link|http://www.example.com/> to a URL.
+###
+.SH "LINK TO URL"
+.IX Header "LINK TO URL"
+This is a link <http://www.example.com/> to a \s-1URL\s0.
+###
+
+###
+=head1 NAME
+
+test - B<test> I<italics> F<file>
+###
+.SH "NAME"
+test \- test italics file
+###
--- /dev/null
+#!/usr/bin/perl -w
+#
+# overstrike.t -- Additional specialized tests for Pod::Text::Overstrike.
+#
+# Copyright 2002, 2004, 2006, 2009 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';
+ }
+ unshift (@INC, '../blib/lib');
+ $| = 1;
+}
+
+use strict;
+
+use Test::More tests => 4;
+BEGIN { use_ok ('Pod::Text::Overstrike') }
+
+my $parser = Pod::Text::Overstrike->new;
+isa_ok ($parser, 'Pod::Text::Overstrike', 'Parser module');
+my $n = 1;
+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;
+ open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n";
+ $parser->parse_from_file ('tmp.pod', \*OUT);
+ close OUT;
+ open (TMP, 'out.tmp') or die "Cannot open out.tmp: $!\n";
+ my $output;
+ {
+ local $/;
+ $output = <TMP>;
+ }
+ close TMP;
+ 1 while unlink ('tmp.pod', 'out.tmp');
+ my $expected = '';
+ while (<DATA>) {
+ last if $_ eq "###\n";
+ $expected .= $_;
+ }
+ is ($output, $expected, "Output correct for test $n");
+ $n++;
+}
+
+# Below the marker are bits of POD and corresponding expected output. This is
+# used to test specific features or problems with Pod::Text::Termcap. The
+# input and output are separated by lines containing only ###.
+
+__DATA__
+
+###
+=head1 WRAPPING
+
+B<I<Do>> I<B<not>> B<I<include>> B<I<formatting codes when>> B<I<wrapping>>.
+###
+W\bWR\bRA\bAP\bPP\bPI\bIN\bNG\bG
+ D\bDo\bo _\bn_\bo_\bt i\bin\bnc\bcl\blu\bud\bde\be f\bfo\bor\brm\bma\bat\btt\bti\bin\bng\bg \b c\bco\bod\bde\bes\bs \b w\bwh\bhe\ben\bn w\bwr\bra\bap\bpp\bpi\bin\bng\bg.
+
+###
+
+###
+=head1 TAG WIDTH
+
+=over 10
+
+=item 12345678
+
+A
+
+=item B<12345678>
+
+B
+
+=item 1
+
+C
+
+=item B<1>
+
+D
+
+=back
+###
+T\bTA\bAG\bG \b W\bWI\bID\bDT\bTH\bH
+ 12345678 A
+
+ 1\b12\b23\b34\b45\b56\b67\b78\b8 B
+
+ 1 C
+
+ 1\b1 D
+
+###
#
# parselink.t -- Tests for Pod::ParseLink.
#
-# Copyright 2001 by Russ Allbery <rra@stanford.edu>
+# Copyright 2001, 2009 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.
# The format of each entry in this array is the L<> text followed by the
-# five-element parse returned by parselink. When adding a new test, also
-# increment the test count in the BEGIN block below. We don't use any of the
-# fancy test modules intentionally for backward compatibility to older
-# versions of Perl.
-@TESTS = (
+# five-element parse returned by parselink.
+our @TESTS = (
[ 'foo',
undef, 'foo', 'foo', undef, 'pod' ],
[ 'news:yld72axzc8.fsf@windlord.stanford.edu',
undef, 'news:yld72axzc8.fsf@windlord.stanford.edu',
- 'news:yld72axzc8.fsf@windlord.stanford.edu', undef, 'url' ]
+ 'news:yld72axzc8.fsf@windlord.stanford.edu', undef, 'url' ],
+
+ [ 'link|http://www.perl.org/',
+ 'link', 'link', 'http://www.perl.org/', undef, 'url' ],
+
+ [ '0|http://www.perl.org/',
+ '0', '0', 'http://www.perl.org/', undef, 'url' ],
+
+ [ '0|Pod::Parser',
+ '0', '0', 'Pod::Parser', undef, 'pod' ],
);
BEGIN {
chdir 't' if -d 't';
unshift (@INC, '../blib/lib');
$| = 1;
- print "1..25\n";
}
-END {
- print "not ok 1\n" unless $loaded;
-}
+use strict;
-use Pod::ParseLink;
-$loaded = 1;
-print "ok 1\n";
+use Test::More tests => 28;
+BEGIN { use_ok ('Pod::ParseLink') }
# Used for reporting test failures.
my @names = qw(text inferred name section type);
-my $n = 2;
for (@TESTS) {
my @expected = @$_;
my $link = shift @expected;
my @results = parselink ($link);
- my $okay = 1;
- for (0..4) {
- # Make sure to check undef explicitly; we don't want undef to match
- # the empty string because they're semantically different.
- unless ((!defined ($results[$_]) && !defined ($expected[$_]))
- || (defined ($results[$_]) && defined ($expected[$_])
- && $results[$_] eq $expected[$_])) {
- print "not ok $n\n" if $okay;
- print "# Incorrect $names[$_]:\n";
- print "# expected: $expected[$_]\n";
- print "# seen: $results[$_]\n";
- $okay = 0;
- }
- }
- print "ok $n\n" if $okay;
- $n++;
+ my $pretty = $link;
+ $pretty =~ s/\n/\\n/g;
+ is_deeply (\@results, \@expected, $pretty);
}
#
# pod-parser.t -- Tests for backward compatibility with Pod::Parser.
#
-# Copyright 2006, 2008 by Russ Allbery <rra@stanford.edu>
+# Copyright 2006, 2008, 2009 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.
chdir 't' if -d 't';
if ($ENV{PERL_CORE}) {
@INC = '../lib';
- } else {
- unshift (@INC, '../blib/lib');
}
unshift (@INC, '../blib/lib');
$| = 1;
- print "1..4\n";
}
-my $loaded;
-
-END {
- print "not ok 1\n" unless $loaded;
-}
-
-use Pod::Man;
-use Pod::Text;
use strict;
-$loaded = 1;
-print "ok 1\n";
+use Test::More tests => 7;
+BEGIN {
+ use_ok ('Pod::Man');
+ use_ok ('Pod::Text');
+}
-my $parser = Pod::Man->new or die "Cannot create parser\n";
+my $parser = Pod::Man->new;
+isa_ok ($parser, 'Pod::Man', 'Pod::Man parser object');
open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n";
print TMP "Some random B<text>.\n";
close TMP;
$output = <OUT>;
}
close OUT;
-if ($output eq "Some random \\fBtext\\fR.\n") {
- print "ok 2\n";
-} else {
- print "not ok 2\n";
- print "Expected\n========\nSome random \\fBtext\\fR.\n\n";
- print "Output\n======\n$output\n";
-}
+is ($output, "Some random \\fBtext\\fR.\n", 'Pod::Man -cutting output');
-$parser = Pod::Text->new or die "Cannot create parser\n";
+$parser = Pod::Text->new;
+isa_ok ($parser, 'Pod::Text', 'Pod::Text parser object');
open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n";
$parser->parse_from_file ({ -cutting => 0 }, 'tmp.pod', \*OUT);
close OUT;
$output = <OUT>;
}
close OUT;
-if ($output eq " Some random text.\n\n") {
- print "ok 3\n";
-} else {
- print "not ok 3\n";
- print "Expected\n========\n Some random text.\n\n\n";
- print "Output\n======\n$output\n";
-}
+is ($output, " Some random text.\n\n", 'Pod::Text -cutting output');
# Test the pod2text function, particularly with only one argument.
open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n";
$output = <OUT>;
}
close OUT;
-if ($output eq " Some random text.\n\n") {
- print "ok 4\n";
-} else {
- print "not ok 4\n";
- print "Expected\n========\n Some random text.\n\n\n";
- print "Output\n======\n$output\n";
-}
+is ($output, " Some random text.\n\n", 'Pod::Text pod2text function');
-unlink ('tmp.pod', 'out.tmp');
+1 while unlink ('tmp.pod', 'out.tmp');
exit 0;
-#!/usr/bin/perl
+#!/usr/bin/perl -w
#
-# t/pod-spelling.t -- Test POD spelling.
+# Check for spelling errors in POD documentation
#
-# Copyright 2008 Russ Allbery <rra@stanford.edu>
+# Checks all POD files in the tree for spelling problems using Pod::Spell and
+# either aspell or ispell. aspell is preferred. This test is disabled unless
+# RRA_MAINTAINER_TESTS is set, since spelling dictionaries vary too much
+# between environments.
+#
+# Copyright 2008, 2009 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.
-# Called to skip all tests with a reason.
-sub skip_all {
- print "1..0 # Skipped: @_\n";
- exit;
-}
+use strict;
+use Test::More;
-# Skip all spelling tests unless flagged to run maintainer tests.
-skip_all "Spelling tests only run for maintainer"
+# Skip all spelling tests unless the maintainer environment variable is set.
+plan skip_all => 'Spelling tests only run for maintainer'
unless $ENV{RRA_MAINTAINER_TESTS};
-# Make sure we have prerequisites. hunspell is currently not supported due to
-# lack of support for contractions.
+# Load required Perl modules.
eval 'use Test::Pod 1.00';
-skip_all "Test::Pod 1.00 required for testing POD" if $@;
+plan skip_all => 'Test::Pod 1.00 required for testing POD' if $@;
eval 'use Pod::Spell';
-skip_all "Pod::Spell required to test POD spelling" if $@;
+plan skip_all => 'Pod::Spell required to test POD spelling' if $@;
+
+# Locate a spell-checker. hunspell is not currently supported due to its lack
+# of support for contractions (at least in the version in Debian).
my @spell;
my %options = (aspell => [ qw(-d en_US --home-dir=./ list) ],
ispell => [ qw(-d american -l -p /dev/null) ]);
last SEARCH if @spell;
}
}
-skip_all "aspell or ispell required to test POD spelling" unless @spell;
+plan skip_all => 'aspell or ispell required to test POD spelling'
+ unless @spell;
-# Run the test, one for each POD file.
+# Prerequisites are satisfied, so we're going to do some testing. Figure out
+# what POD files we have and from that develop our plan.
$| = 1;
my @pod = all_pod_files ();
-my $count = scalar @pod;
-print "1..$count\n";
-my $n = 1;
+plan tests => scalar @pod;
+
+# Finally, do the checks.
for my $pod (@pod) {
my $child = open (CHILD, '-|');
if (not defined $child) {
die "Cannot fork: $!\n";
} elsif ($child == 0) {
- my $pid = open (SPELL, '|-', @spell)
- or die "Cannot run @spell: $!\n";
+ my $pid = open (SPELL, '|-', @spell) or die "Cannot run @spell: $!\n";
open (POD, '<', $pod) or die "Cannot open $pod: $!\n";
my $parser = Pod::Spell->new;
$parser->parse_from_filehandle (\*POD, \*SPELL);
} else {
my @words = <CHILD>;
close CHILD;
- if ($? != 0) {
- print "ok $n # skip - @spell failed: $?\n";
- } elsif (@words) {
+ SKIP: {
+ skip "@spell failed for $pod", 1 unless $? == 0;
for (@words) {
s/^\s+//;
s/\s+$//;
}
- print "not ok $n\n";
- print " - Misspelled words found in $pod\n";
- print " @words\n";
- } else {
- print "ok $n\n";
+ is ("@words", '', $pod);
}
- $n++;
}
}
-#!/usr/bin/perl
+#!/usr/bin/perl -w
#
-# t/pod.t -- Test POD formatting.
+# Test POD formatting.
+#
+# Copyright 2009 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.
+use strict;
+use Test::More;
eval 'use Test::Pod 1.00';
-if ($@) {
- print "1..1\n";
- print "ok 1 # skip - Test::Pod 1.00 required for testing POD\n";
- exit;
-}
+plan skip_all => "Test::Pod 1.00 required for testing POD" if $@;
all_pod_files_ok ();
#
# termcap.t -- Additional specialized tests for Pod::Text::Termcap.
#
-# Copyright 2002, 2004, 2006 by Russ Allbery <rra@stanford.edu>
+# Copyright 2002, 2004, 2006, 2009 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.
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 strict;
+
+use Test::More tests => 4;
+BEGIN { use_ok ('Pod::Text::Termcap') }
# 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';
-use Pod::Text::Termcap;
-
-$loaded = 1;
-print "ok 1\n";
-
-my $parser = Pod::Text::Termcap->new or die "Cannot create parser\n";
-my $n = 2;
+my $parser = Pod::Text::Termcap->new;
+isa_ok ($parser, 'Pod::Text::Termcap', 'Parser module');
+my $n = 1;
while (<DATA>) {
next until $_ eq "###\n";
open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n";
$output = <TMP>;
}
close TMP;
- unlink ('tmp.pod', 'out.tmp');
+ 1 while 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";
- }
+ is ($output, $expected, "Output correct for test $n");
$n++;
}
\e[1m\e[4mDo\e[m\e[m \e[4m\e[1mnot\e[m\e[m \e[1m\e[4minclude\e[m\e[m \e[1m\e[4mformatting codes when\e[m\e[m \e[1m\e[4mwrapping\e[m\e[m.
###
+
+###
+=head1 TAG WIDTH
+
+=over 10
+
+=item 12345678
+
+A
+
+=item B<12345678>
+
+B
+
+=item 1
+
+C
+
+=item B<1>
+
+D
+
+=back
+###
+\e[1mTAG WIDTH\e[m
+ 12345678 A
+
+ \e[1m12345678\e[m B
+
+ 1 C
+
+ \e[1m1\e[m D
+
+###
#
# text-encoding.t -- Test Pod::Text with various weird encoding combinations.
#
-# Copyright 2002, 2004, 2006, 2007, 2008 by Russ Allbery <rra@stanford.edu>
+# Copyright 2002, 2004, 2006, 2007, 2008, 2009
+# 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.
chdir 't' if -d 't';
if ($ENV{PERL_CORE}) {
@INC = '../lib';
- } else {
- unshift (@INC, '../blib/lib');
}
unshift (@INC, '../blib/lib');
$| = 1;
- print "1..4\n";
-
- # PerlIO encoding support requires Perl 5.8 or later.
- if ($] < 5.008) {
- my $n;
- for $n (1..4) {
- print "ok $n # skip -- Perl 5.8 required for UTF-8 support\n";
- }
- exit;
- }
}
-END {
- print "not ok 1\n" unless $loaded;
-}
+use strict;
-use Pod::Text;
+use Test::More;
-$loaded = 1;
-print "ok 1\n";
+# UTF-8 support requires Perl 5.8 or later.
+BEGIN {
+ if ($] < 5.008) {
+ plan skip_all => 'Perl 5.8 required for encoding support';
+ } else {
+ plan tests => 7;
+ }
+}
+BEGIN { use_ok ('Pod::Text') }
-my $n = 2;
eval { binmode (\*DATA, ':raw') };
eval { binmode (\*STDOUT, ':raw') };
+my $builder = Test::More->builder;
+eval { binmode ($builder->output, ':raw') };
+eval { binmode ($builder->failure_output, ':raw') };
+
+my $n = 1;
while (<DATA>) {
my %opts;
- $opts{utf8} = 1 if $n == 4;
- my $parser = Pod::Text->new (%opts) or die "Cannot create parser\n";
+ $opts{utf8} = 1 if $n == 3;
next until $_ eq "###\n";
+ my $parser = Pod::Text->new (%opts);
+ isa_ok ($parser, 'Pod::Text', 'Parser object');
open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n";
eval { binmode (\*TMP, ':raw') };
while (<DATA>) {
$output = <TMP>;
}
close TMP;
- unlink ('tmp.pod', 'out.tmp');
+ 1 while 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";
- }
+ is ($output, $expected, "Output correct for test $n");
$n++;
}
#
# text-options.t -- Additional tests for Pod::Text options.
#
-# Copyright 2002, 2004, 2006, 2008 by Russ Allbery <rra@stanford.edu>
+# Copyright 2002, 2004, 2006, 2008, 2009 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.
chdir 't' if -d 't';
if ($ENV{PERL_CORE}) {
@INC = '../lib';
- } else {
- unshift (@INC, '../blib/lib');
}
unshift (@INC, '../blib/lib');
$| = 1;
- print "1..13\n";
}
-END {
- print "not ok 1\n" unless $loaded;
-}
+use strict;
-use Pod::Text;
+use Test::More tests => 19;
+BEGIN { use_ok ('Pod::Text') }
# Redirect stderr to a file.
sub stderr_save {
close OLDERR;
}
-$loaded = 1;
-print "ok 1\n";
-
-my $n = 2;
+my $n = 1;
while (<DATA>) {
my %options;
next until $_ eq "###\n";
print TMP $_;
}
close TMP;
- my $parser = Pod::Text->new (%options) or die "Cannot create parser\n";
+ my $parser = Pod::Text->new (%options);
+ isa_ok ($parser, 'Pod::Text', 'Parser object');
open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n";
stderr_save;
$parser->parse_from_file ('tmp.pod', \*OUT);
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++;
+ is ($output, $expected, "Ouput correct for test $n");
open (ERR, 'out.err') or die "Cannot open out.err: $!\n";
my $errors;
{
$errors = <ERR>;
}
close ERR;
- unlink ('out.err');
+ 1 while unlink ('out.err');
$expected = '';
while (<DATA>) {
last if $_ eq "###\n";
$expected .= $_;
}
- if ($errors eq $expected) {
- print "ok $n\n";
- } else {
- print "not ok $n\n";
- print "Expected errors:\n ${expected}Errors:\n $errors";
- }
+ is ($errors, $expected, "Errors correct for test $n");
$n++;
}
# Below the marker are bits of POD and corresponding expected text output.
# This is used to test specific features or problems with Pod::Text. The
-# input and output are separated by lines containing only ###.
+# options, input, output, and errors are separated by lines containing only
+# ###.
__DATA__
#
# text-utf8.t -- Test Pod::Text with UTF-8 input.
#
-# Copyright 2002, 2004, 2006, 2007, 2008 by Russ Allbery <rra@stanford.edu>
+# Copyright 2002, 2004, 2006, 2007, 2008, 2009
+# 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.
chdir 't' if -d 't';
if ($ENV{PERL_CORE}) {
@INC = '../lib';
- } else {
- unshift (@INC, '../blib/lib');
}
unshift (@INC, '../blib/lib');
$| = 1;
- print "1..3\n";
-
- # UTF-8 support requires Perl 5.8 or later.
- if ($] < 5.008) {
- my $n;
- for $n (1..3) {
- print "ok $n # skip -- Perl 5.8 required for UTF-8 support\n";
- }
- exit;
- }
}
-END {
- print "not ok 1\n" unless $loaded;
-}
+use strict;
-use Pod::Text;
+use Test::More;
-$loaded = 1;
-print "ok 1\n";
+# UTF-8 support requires Perl 5.8 or later.
+BEGIN {
+ if ($] < 5.008) {
+ plan skip_all => 'Perl 5.8 required for UTF-8 support';
+ } else {
+ plan tests => 4;
+ }
+}
+BEGIN { use_ok ('Pod::Text') }
-my $parser = Pod::Text->new or die "Cannot create parser\n";
-my $n = 2;
+my $parser = Pod::Text->new;
+isa_ok ($parser, 'Pod::Text', 'Parser object');
+my $n = 1;
eval { binmode (\*DATA, ':encoding(utf-8)') };
eval { binmode (\*STDOUT, ':encoding(utf-8)') };
+my $builder = Test::More->builder;
+eval { binmode ($builder->output, ':encoding(utf-8)') };
+eval { binmode ($builder->failure_output, ':encoding(utf-8)') };
while (<DATA>) {
next until $_ eq "###\n";
open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n";
$output = <TMP>;
}
close TMP;
- unlink ('tmp.pod', 'out.tmp');
+ 1 while 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";
- }
+ is ($output, $expected, "Output correct for test $n");
$n++;
}
chdir 't' if -d 't';
if ($ENV{PERL_CORE}) {
@INC = '../lib';
- } else {
- unshift (@INC, '../blib/lib');
}
unshift (@INC, '../blib/lib');
$| = 1;
- print "1..6\n";
}
-END {
- print "not ok 1\n" unless $loaded;
-}
+use strict;
-use Pod::Text;
use Pod::Simple;
+use Test::More tests => 8;
+BEGIN { use_ok ('Pod::Text') }
-$loaded = 1;
-print "ok 1\n";
-
-my $parser = Pod::Text->new or die "Cannot create parser\n";
-my $n = 2;
+my $parser = Pod::Text->new;
+isa_ok ($parser, 'Pod::Text', 'Parser object');
+my $n = 1;
while (<DATA>) {
next until $_ eq "###\n";
open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n";
$output = <TMP>;
}
close TMP;
- unlink ('tmp.pod', 'out.tmp');
+ 1 while unlink ('tmp.pod', 'out.tmp');
my $expected = '';
while (<DATA>) {
last if $_ eq "###\n";
$expected .= $_;
}
- if ($output eq $expected) {
- print "ok $n\n";
- } elsif ($n == 4 && $Pod::Simple::VERSION < 3.06) {
- print "ok $n # skip Pod::Simple S<> parsing bug\n";
- } else {
- print "not ok $n\n";
- print "Expected\n========\n$expected\nOutput\n======\n$output\n";
- }
+ is ($output, $expected, "Output correct for test $n");
$n++;
}
line3
###
+
+###
+=head1 LINK TO URL
+
+This is a L<link|http://www.example.com/> to a URL.
+###
+LINK TO URL
+ This is a link <http://www.example.com/> to a URL.
+
+###
Manual page indexers are often extremely picky about the format of this
section, so don't put anything in it except this line. A single dash, and
only a single dash, should separate the list of programs or functions from
-the description. Functions should not be qualified with C<()> or the like.
+the description. Do not use any markup such as CE<lt>E<gt> or
+BE<lt>E<gt>. Functions should not be qualified with C<()> or the like.
The description should ideally fit on a single line, even if a man program
replaces the dash with a few tabs.