dslinux/user/perl/lib/Pod/t Functions.t InputObjects.t Select.t Usage.t basic.cap basic.clr basic.man basic.ovr basic.pod basic.t basic.txt contains_pod.t eol.t htmlescp.pod htmlescp.t htmllink.pod htmllink.t htmlview.pod htmlview.t man.t parselink.t pod2html-lib.pl pod2latex.t text-errors.t text-options.t text.t user.t utils.t
cayenne
dslinux_cayenne at user.in-berlin.de
Mon Dec 4 18:01:01 CET 2006
Update of /cvsroot/dslinux/dslinux/user/perl/lib/Pod/t
In directory antilope:/tmp/cvs-serv17422/lib/Pod/t
Added Files:
Functions.t InputObjects.t Select.t Usage.t basic.cap
basic.clr basic.man basic.ovr basic.pod basic.t basic.txt
contains_pod.t eol.t htmlescp.pod htmlescp.t htmllink.pod
htmllink.t htmlview.pod htmlview.t man.t parselink.t
pod2html-lib.pl pod2latex.t text-errors.t text-options.t
text.t user.t utils.t
Log Message:
Adding fresh perl source to HEAD to branch from
--- NEW FILE: parselink.t ---
#!/usr/bin/perl -w
# $Id: parselink.t,v 1.1 2006-12-04 17:00:58 dslinux_cayenne Exp $
#
# parselink.t -- Tests for Pod::ParseLink.
#
# Copyright 2001 by Russ Allbery <rra at 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 = (
[ 'foo',
undef, 'foo', 'foo', undef, 'pod' ],
[ 'foo|bar',
'foo', 'foo', 'bar', undef, 'pod' ],
[ 'foo/bar',
undef, '"bar" in foo', 'foo', 'bar', 'pod' ],
[ 'foo/"baz boo"',
undef, '"baz boo" in foo', 'foo', 'baz boo', 'pod' ],
[ '/bar',
undef, '"bar"', undef, 'bar', 'pod' ],
[ '/"baz boo"',
undef, '"baz boo"', undef, 'baz boo', 'pod' ],
[ '/baz boo',
undef, '"baz boo"', undef, 'baz boo', 'pod' ],
[ 'foo bar/baz boo',
undef, '"baz boo" in foo bar', 'foo bar', 'baz boo', 'pod' ],
[ 'foo bar / baz boo',
undef, '"baz boo" in foo bar', 'foo bar', 'baz boo', 'pod' ],
[ "foo\nbar\nbaz\n/\nboo",
undef, '"boo" in foo bar baz', 'foo bar baz', 'boo', 'pod' ],
[ 'anchor|name/section',
'anchor', 'anchor', 'name', 'section', 'pod' ],
[ '"boo var baz"',
undef, '"boo var baz"', undef, 'boo var baz', 'pod' ],
[ 'bar baz',
undef, '"bar baz"', undef, 'bar baz', 'pod' ],
[ '"boo bar baz / baz boo"',
undef, '"boo bar baz / baz boo"', undef, 'boo bar baz / baz boo',
'pod' ],
[ 'fooZ<>bar',
undef, 'fooZ<>bar', 'fooZ<>bar', undef, 'pod' ],
[ 'Testing I<italics>|foo/bar',
'Testing I<italics>', 'Testing I<italics>', 'foo', 'bar', 'pod' ],
[ 'foo/I<Italic> text',
undef, '"I<Italic> text" in foo', 'foo', 'I<Italic> text', 'pod' ],
[ 'fooE<verbar>barZ<>/Section C<with> I<B<other> markup',
undef, '"Section C<with> I<B<other> markup" in fooE<verbar>barZ<>',
'fooE<verbar>barZ<>', 'Section C<with> I<B<other> markup', 'pod' ],
[ 'Nested L<http://www.perl.org/>|fooE<sol>bar',
'Nested L<http://www.perl.org/>', 'Nested L<http://www.perl.org/>',
'fooE<sol>bar', undef, 'pod' ],
[ 'ls(1)',
undef, 'ls(1)', 'ls(1)', undef, 'man' ],
[ ' perlfunc(1)/open ',
undef, '"open" in perlfunc(1)', 'perlfunc(1)', 'open', 'man' ],
[ 'some manual page|perl(1)',
'some manual page', 'some manual page', 'perl(1)', undef, 'man' ],
[ 'http://www.perl.org/',
undef, 'http://www.perl.org/', 'http://www.perl.org/', undef, 'url' ],
[ 'news:yld72axzc8.fsf at windlord.stanford.edu',
undef, 'news:yld72axzc8.fsf at windlord.stanford.edu',
'news:yld72axzc8.fsf at windlord.stanford.edu', undef, 'url' ]
);
BEGIN {
chdir 't' if -d 't';
unshift (@INC, '../blib/lib');
$| = 1;
print "1..25\n";
}
END {
print "not ok 1\n" unless $loaded;
}
use Pod::ParseLink;
$loaded = 1;
print "ok 1\n";
# 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++;
}
--- NEW FILE: htmllink.t ---
#!/usr/bin/perl -w # -*- perl -*-
BEGIN {
chdir 't' if -d 't';
unshift @INC, '../lib';
unshift @INC, '../lib/Pod/t';
require "pod2html-lib.pl";
}
use strict;
use Test::More tests => 1;
TODO: {
local $TODO = "item 2 doesn't work as expected";
convert_n_test("htmllink", "html links");
}
__DATA__
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>htmllink - Test HTML links</title>
<link rev="made" href="mailto:" />
</head>
<body style="background-color: white">
<p><a name="__index__"></a></p>
<!-- INDEX BEGIN -->
<ul>
<li><a href="#name">NAME</a></li>
<li><a href="#links">LINKS</a></li>
<li><a href="#targets">TARGETS</a></li>
<ul>
<li><a href="#section1">section1</a></li>
<li><a href="#section_2">section 2</a></li>
<li><a href="#section_three">section three</a></li>
</ul>
</ul>
<!-- INDEX END -->
<hr />
<p>
</p>
<h1><a name="name">NAME</a></h1>
<p>htmllink - Test HTML links</p>
<p>
</p>
<hr />
<h1><a name="links">LINKS</a></h1>
<p><a href="#section1">section1</a></p>
<p><a href="#section_2">section 2</a></p>
<p><a href="#section_three">section three</a></p>
<p><a href="#item_item1">item1</a></p>
<p><a href="#item_item_2">item 2</a></p>
<p><a href="#item_item_three">item three</a></p>
<p><a href="#section1">section1</a></p>
<p><a href="#section_2">section 2</a></p>
<p><a href="#section_three">section three</a></p>
<p><a href="#item_item1">item1</a></p>
<p><a href="#item_item_2">item 2</a></p>
<p><a href="#item_item_three">item three</a></p>
<p><a href="#section1">section1</a></p>
<p><a href="#section_2">section 2</a></p>
<p><a href="#section_three">section three</a></p>
<p><a href="#item_item1">item1</a></p>
<p><a href="#item_item_2">item 2</a></p>
<p><a href="#item_item_three">item three</a></p>
<p><a href="#section1">text</a></p>
<p><a href="#section_2">text</a></p>
<p><a href="#section_three">text</a></p>
<p><a href="#item_item1">text</a></p>
<p><a href="#item_item_2">text</a></p>
<p><a href="#item_item_three">text</a></p>
<p><a href="#section1">text</a></p>
<p><a href="#section_2">text</a></p>
<p><a href="#section_three">text</a></p>
<p><a href="#item_item1">text</a></p>
<p><a href="#item_item_2">text</a></p>
<p><a href="#item_item_three">text</a></p>
<p><a href="#section1">text</a></p>
<p><a href="#section_2">text</a></p>
<p><a href="#section_three">text</a></p>
<p><a href="#item_item1">text</a></p>
<p><a href="#item_item_2">text</a></p>
<p><a href="#item_item_three">text</a></p>
<p>
</p>
<hr />
<h1><a name="targets">TARGETS</a></h1>
<p>
</p>
<h2><a name="section1">section1</a></h2>
<p>This is section one.</p>
<p>
</p>
<h2><a name="section_2">section 2</a></h2>
<p>This is section two.</p>
<p>
</p>
<h2><a name="section_three">section three</a></h2>
<p>This is section three.</p>
<dl>
<dt><strong><a name="item_item1">item1</a></strong><br />
</dt>
<dd>
This is item one.
</dd>
<p></p>
<dt><strong><a name="item_item_2">item 2</a></strong><br />
</dt>
<dd>
This is item two.
</dd>
<p></p>
<dt><strong><a name="item_item_three">item three</a></strong><br />
</dt>
<dd>
This is item three.
</dd>
<p></p></dl>
</body>
</html>
--- NEW FILE: Usage.t ---
#!perl
use strict;
BEGIN {
chdir 't' if -d 't';
@INC = '../lib';
}
use File::Basename;
use File::Spec;
use Test::More;
plan tests => 8;
use_ok( 'Pod::Usage' );
# Test verbose level 0
my $vbl_0 = << 'EOMSG';
Usage:
The SYNOPSIS section is displayed with -verbose >= 0.
EOMSG
my $fake_out = tie *FAKEOUT, 'CatchOut';
pod2usage({ -verbose => 0, -exit => 'noexit', -output => \*FAKEOUT });
is( $$fake_out, $vbl_0, 'Verbose level 0' );
my $msg = "Prefix message for pod2usage()";
$$fake_out = '';
pod2usage({ -verbose => 0, -exit => 'noexit', -output => \*FAKEOUT,
-message => $msg });
is( $$fake_out, "$msg\n$vbl_0", '-message parameter' );
SKIP: {
my( $file, $path ) = fileparse( $0 );
skip( 'File in current directory', 2 ) if -e $file;
$$fake_out = '';
eval {
pod2usage({ -verbose => 0, -exit => 'noexit',
-output => \*FAKEOUT, -input => $file });
};
like( $@, qr/^Can't open $file for reading:/,
'File not found without -pathlist' );
eval {
pod2usage({ -verbose => 0, -exit => 'noexit',
-output => \*FAKEOUT, -input => $file,
-pathlist => $path });
};
is( $$fake_out, $vbl_0, '-pathlist parameter' );
}
SKIP: { # Test exit status from pod2usage()
skip "Exit status broken on Mac OS", 1 if $^O eq 'MacOS';
my $exit = ($^O eq 'VMS' ? 2 : 42);
my $dev_null = File::Spec->devnull;
my $args = join ", ", (
"-verbose => 0",
"-exit => $exit",
"-output => q{$dev_null}",
"-input => q{$0}",
);
my $cq = (($^O eq 'MSWin32'
|| $^O eq 'NetWare'
|| $^O eq 'VMS') ? '"'
: "");
my @params = ( "${cq}-I../lib$cq", "${cq}-MPod::Usage$cq", '-e' );
my $prg = qq[${cq}pod2usage({ $args })$cq];
my @cmd = ( $^X, @params, $prg );
print "# cmd = @cmd\n";
is( system( @cmd ) >> 8, $exit, 'Exit status of pod2usage()' );
}
# Test verbose level 1
my $vbl_1 = << 'EOMSG';
Usage:
The SYNOPSIS section is displayed with -verbose >= 0.
Options:
The OPTIONS section is displayed with -verbose >= 1.
Arguments:
The ARGUMENTS section is displayed with -verbose >= 1.
EOMSG
$$fake_out = '';
pod2usage( { -verbose => 1, -exit => 'noexit', -output => \*FAKEOUT } );
is( $$fake_out, $vbl_1, 'Verbose level 1' );
# Test verbose level 2
$$fake_out = '';
require Pod::Text; # Pod::Usage->isa( 'Pod::Text' )
( my $p2tp = new Pod::Text )->parse_from_file( $0, \*FAKEOUT );
my $pod2text = $$fake_out;
$$fake_out = '';
pod2usage( { -verbose => 2, -exit => 'noexit', -output => \*FAKEOUT } );
my $pod2usage = $$fake_out;
is( $pod2usage, $pod2text, 'Verbose level >= 2 eq pod2text' );
package CatchOut;
sub TIEHANDLE { bless \( my $self ), shift }
sub PRINT { my $self = shift; $$self .= $_[0] }
__END__
=head1 NAME
Usage.t - Tests for Pod::Usage
=head1 SYNOPSIS
The B<SYNOPSIS> section is displayed with -verbose >= 0.
=head1 DESCRIPTION
Testing Pod::Usage. This section is not displayed with -verbose < 2.
=head1 OPTIONS
The B<OPTIONS> section is displayed with -verbose >= 1.
=head1 ARGUMENTS
The B<ARGUMENTS> section is displayed with -verbose >= 1.
=head1 AUTHOR
20020105 Abe Timmerman <abe at ztreet.demon.nl>
=cut
--- NEW FILE: basic.ovr ---
(This appears to be a binary file; contents omitted.)
--- NEW FILE: contains_pod.t ---
#!/usr/bin/env perl
# Copyright (C) 2005 Joshua Hoblitt
#
# $Id: contains_pod.t,v 1.1 2006-12-04 17:00:58 dslinux_cayenne Exp $
use strict;
BEGIN {
if( $ENV{PERL_CORE} ) {
chdir 't';
@INC = '../lib';
} else {
use lib qw( ./lib );
}
}
use Test::More tests => 1;
use Pod::Find qw( contains_pod );
{
ok(contains_pod('lib/contains_pod.xr'), "contains pod");
}
--- NEW FILE: pod2html-lib.pl ---
require Cwd;
require Pod::Html;
require Config;
use File::Spec::Functions;
sub convert_n_test {
my($podfile, $testname) = @_;
my $cwd = Cwd::cwd();
my $base_dir = catdir $cwd, updir(), "lib", "Pod";
my $new_dir = catdir $base_dir, "t";
my $infile = catfile $new_dir, "$podfile.pod";
my $outfile = catfile $new_dir, "$podfile.html";
Pod::Html::pod2html(
"--podpath=t",
"--podroot=$base_dir",
"--htmlroot=/",
"--infile=$infile",
"--outfile=$outfile"
);
my ($expect, $result);
{
local $/;
# expected
$expect = <DATA>;
$expect =~ s/\[PERLADMIN\]/$Config::Config{perladmin}/;
if (ord("A") == 193) { # EBCDIC.
$expect =~ s/item_mat%3c%21%3e/item_mat%4c%5a%6e/;
}
# result
open my $in, $outfile or die "cannot open $outfile: $!";
$result = <$in>;
close $in;
}
ok($expect eq $result, $testname) or do {
my $diff = '/bin/diff';
-x $diff or $diff = '/usr/bin/diff';
if (-x $diff) {
my $expectfile = "pod2html-lib.tmp";
open my $tmpfile, ">", $expectfile or die $!;
print $tmpfile $expect;
close $tmpfile;
my $diffopt = $^O eq 'linux' ? 'u' : 'c';
open my $diff, "diff -$diffopt $expectfile $outfile |" or die $!;
print "# $_" while <$diff>;
close $diff;
unlink $expectfile;
}
};
# pod2html creates these
1 while unlink $outfile;
1 while unlink "pod2htmd.tmp";
1 while unlink "pod2htmi.tmp";
}
1;
--- NEW FILE: pod2latex.t ---
#!perl
# 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 Test;
use strict;
BEGIN { plan tests => 177 }
use Pod::LaTeX;
# The link parsing changed between v0.22 and v0.30 of Pod::ParseUtils
use Pod::ParseUtils;
my $linkver = $Pod::ParseUtils::VERSION;
# 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 = <DATA>) {
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 = <INFH>;
ok(@output, @reference);
for my $i (0..$#reference) {
next if $reference[$i] =~ /^%%/; # skip timestamp comments
# if we are running a new version of Pod::ParseUtils we need
# to change the link text. This is a kluge until we drop support
# for older versions of Pod::ParseUtils
if ($linkver < 0.29 && $output[$i] =~ /manpage/) {
# convert our expectations from new to old new format
$reference[$i] =~ s/Standard link: \\emph\{Pod::LaTeX\}/Standard link: the \\emph\{Pod::LaTeX\} manpage/;
$reference[$i] =~ s/\\textsf\{sec\} in \\emph\{Pod::LaTeX\}/the section on \\textsf\{sec\} in the \\emph\{Pod::LaTeX\} manpage/;
}
ok($output[$i], $reference[$i]);
}
close(INFH) or die "Error closing INFH test.tex: $!\n";
__DATA__
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{textcomp}
%% Latex generated from POD in document (unknown)
%% Using the perl module Pod::LaTeX
%% Converted on Sat Apr 5 21:16:02 2003
\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: \emph{Pod::LaTeX}.
Now refer to an external section: \textsf{sec} in \emph{Pod::LaTeX}
\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.
\item[{square [ bracket in item}] \mbox{}
Square bracket content
\end{description}
And this should be an enumerated list without any cruft after the numbers or additional numbers at all.
\begin{enumerate}
\item
item 1
\item
item 2
\end{enumerate}
\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 \textfractionsolidus{} (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<very important>) 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<use strict> and C<-w> (or C<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.
=back
=head1 Links
This link should just include one word: L<Pod::LaTeX|Pod::LaTeX>
This link should include the text C<test> even though
it refers to C<Pod::LaTeX>: L<test|Pod::LaTeX>.
Standard link: L<Pod::LaTeX>.
Now refer to an external section: L<Pod::LaTeX/"sec">
=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<something across> the 40 char boundary
This is item content.
=item square [ bracket in item
Square bracket content
=back
And this should be an enumerated list without any cruft after the numbers or additional numbers at all.
=over 4
=item 1)
item 1
=item 2.
item 2
=back
=head1 Escapes
Test some normal escapes such as < (lt) and > (gt) and | (verbar) and
~ (tilde) and & (amp) as well as E<lt> (Esc lt) and E<verbar> (Esc
verbar) and E<sol> (Esc sol) and E<gt> (Esc gt) and E<amp> (Esc amp)
and E<quot> (Esc quot) and even E<alpha> (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
--- NEW FILE: basic.pod ---
=head1 NAME
basic.pod - Test of various basic POD features in translators.
=head1 HEADINGS
Try a few different levels of headings, with embedded formatting codes and
other interesting bits.
=head1 This C<is> a "level 1" heading
=head2 ``Level'' "2 I<heading>
=head3 Level 3 B<heading I<with C<weird F<stuff "" (double quote)>>>>
=head4 Level "4 C<heading>
Now try again with B<intermixed> F<text>.
=head1 This C<is> a "level 1" heading
Text.
=head2 ``Level'' 2 I<heading>
Text.
=head3 Level 3 B<heading I<with C<weird F<stuff>>>>
Text.
=head4 Level "4 C<heading>
Text.
=head1 LINKS
These are all taken from the Pod::Parser tests.
Try out I<LOTS> of different ways of specifying references:
Reference the L<manpage/section>
Reference the L<manpage / section>
Reference the L<manpage/ section>
Reference the L<manpage /section>
Reference the L<"manpage/section">
Reference the L<"manpage"/section>
Reference the L<manpage/"section">
Reference the L<manpage/
section>
Reference the L<manpage
/section>
Now try it using the new "|" stuff ...
Reference the L<thistext|manpage/section>|
Reference the L<thistext | manpage / section>|
Reference the L<thistext| manpage/ section>|
Reference the L<thistext |manpage /section>|
Reference the L<thistext|
"manpage/section">|
Reference the L<thistext
|"manpage"/section>|
Reference the L<thistext|manpage/"section">|
Reference the L<thistext|
manpage/
section>|
Reference the L<thistext
|manpage
/section>|
And then throw in a few new ones of my own.
L<foo>
L<foo|bar>
L<foo/bar>
L<foo/"baz boo">
L</bar>
L</"baz boo">
L</baz boo>
L<foo bar/baz boo>
L<foo bar / baz boo>
L<foo
bar
baz
/
boo>
L<"boo var baz">
L<bar baz>
L<"boo bar baz / baz boo">
L</boo>, L</bar>, and L</baz>
L<fooZ<>bar>
L<Testing I<italics>|foo/bar>
L<foo/I<Italic> text>
L<fooE<verbar>barZ<>/Section C<with> I<B<other> markup>>
L<Nested L<http://www.perl.org/>|fooE<sol>bar>
=head1 OVER AND ITEMS
Taken from Pod::Parser tests, this is a test to ensure that multiline
=item paragraphs get indented appropriately.
=over 4
=item This
is
a
test.
=back
There should be whitespace now before this line.
Taken from Pod::Parser tests, this is a test to ensure the nested =item
paragraphs get indented appropriately.
=over 2
=item 1
First section.
=over 2
=item a
this is item a
=item b
this is item b
=back
=item 2
Second section.
=over 2
=item a
this is item a
=item b
this is item b
=item c
=item d
This is item c & d.
=back
=back
Now some additional weirdness of our own. Make sure that multiple tags
for one paragraph are properly compacted.
=over 4
=item "foo"
=item B<bar>
=item C<baz>
There shouldn't be any spaces between any of these item tags; this idiom
is used in perlfunc.
=item Some longer item text
Just to make sure that we test paragraphs where the item text doesn't fit
in the margin of the paragraph (and make sure that this paragraph fills a
few lines).
Let's also make it multiple paragraphs to be sure that works.
=back
Test use of =over without =item as a block "quote" or block paragraph.
=over 4
This should be indented four spaces but otherwise formatted the same as
any other regular text paragraph. Make sure it's long enough to see the
results of the formatting.....
=back
Now try the same thing nested, and make sure that the indentation is reset
back properly.
=over 4
=over 4
This paragraph should be doubly indented.
=back
This paragraph should only be singly indented.
=over 4
=item
This is an item in the middle of a block-quote, which should be allowed.
=item
We're also testing tagless item commands.
=back
Should be back to the single level of indentation.
=back
Should be back to regular indentation.
Now also check the transformation of * into real bullets for man pages.
=over
=item *
An item. We're also testing using =over without a number, and making sure
that item text wraps properly.
=item *
Another item.
=back
and now test the numbering of item blocks.
=over 4
=item 1.
First item.
=item 2.
Second item.
=back
=head1 FORMATTING CODES
Another test taken from Pod::Parser.
This is a test to see if I can do not only C<$self> and C<method()>, but
also C<< $self->method() >> and C<< $self->{FIELDNAME} >> and
C<< $Foo <=> $Bar >> without resorting to escape sequences. If
I want to refer to the right-shift operator I can do something
like C<<< $x >> 3 >>> or even C<<<< $y >> 5 >>>>.
Now for the grand finale of C<< $self->method()->{FIELDNAME} = {FOO=>BAR} >>.
And I also want to make sure that newlines work like this
C<<<
$self->{FOOBAR} >> 3 and [$b => $a]->[$a <=> $b]
>>>
Of course I should still be able to do all this I<with> escape sequences
too: C<$self-E<gt>method()> and C<$self-E<gt>{FIELDNAME}> and
C<{FOO=E<gt>BAR}>.
Dont forget C<$self-E<gt>method()-E<gt>{FIELDNAME} = {FOO=E<gt>BAR}>.
And make sure that C<0> works too!
Now, if I use << or >> as my delimiters, then I have to use whitespace.
So things like C<<$self->method()>> and C<<$self->{FIELDNAME}>> wont end
up doing what you might expect since the first > will still terminate
the first < seen.
Lets make sure these work for empty ones too, like C<< >> and C<< >> >>
(just to be obnoxious)
The statement: C<This is dog kind's I<finest> hour!> is a parody of a
quotation from Winston Churchill.
The following tests are added to those:
Make sure that a few othZ<>er odd I<Z<>things> still work. This should be
a vertical bar: E<verbar>. Here's a test of a few more special escapes
that have to be supported:
=over 3
=item E<amp>
An ampersand.
=item E<apos>
An apostrophe.
=item E<lt>
A less-than sign.
=item E<gt>
A greater-than sign.
=item E<quot>
A double quotation mark.
=item E<sol>
A forward slash.
=back
Try to get this bit of text over towards the edge so S<|that all of this
text inside SE<lt>E<gt> won't|> be wrapped. Also test the
|sameE<nbsp>thingE<nbsp>withE<nbsp>non-breakingS< spaces>.|
There is a soft hyE<shy>phen in hyphen at hy-phen.
This is a test of an X<index entry>index entry.
=head1 VERBATIM
Throw in a few verbatim paragraphs.
use Term::ANSIColor;
print color 'bold blue';
print "This text is bold blue.\n";
print color 'reset';
print "This text is normal.\n";
print colored ("Yellow on magenta.\n", 'yellow on_magenta');
print "This text is normal.\n";
print colored ['yellow on_magenta'], "Yellow on magenta.\n";
use Term::ANSIColor qw(uncolor);
print uncolor '01;31', "\n";
But this isn't verbatim (make sure it wraps properly), and the next
paragraph is again:
use Term::ANSIColor qw(:constants);
print BOLD, BLUE, "This text is in bold blue.\n", RESET;
use Term::ANSIColor qw(:constants); $Term::ANSIColor::AUTORESET = 1; print BOLD BLUE "This text is in bold blue.\n"; print "This text is normal.\n";
(Ugh, that's obnoxiously long.) Try different spacing:
Starting with a tab.
Not
starting
with
a
tab. But this should still be verbatim.
As should this.
This isn't.
This is. And this: is an internal tab. It should be:
|--| <= lined up with that.
(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.)
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
--- NEW FILE: htmlview.t ---
#!/usr/bin/perl -w # -*- perl -*-
BEGIN {
chdir 't' if -d 't';
unshift @INC, '../lib';
unshift @INC, '../lib/Pod/t';
require "pod2html-lib.pl";
}
use strict;
use Test::More tests => 1;
convert_n_test("htmlview", "html rendering");
__DATA__
<?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>NAME</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rev="made" href="mailto:[PERLADMIN]" />
</head>
<body style="background-color: white">
<p><a name="__index__"></a></p>
<!-- INDEX BEGIN -->
<ul>
<li><a href="#name">NAME</a></li>
<li><a href="#synopsis">SYNOPSIS</a></li>
<li><a href="#description">DESCRIPTION</a></li>
<li><a href="#methods____other_stuff">METHODS => OTHER STUFF</a></li>
<ul>
<li><a href="#new__"><code>new()</code></a></li>
<li><a href="#old__"><code>old()</code></a></li>
</ul>
<li><a href="#testing_for_and_begin">TESTING FOR AND BEGIN</a></li>
<li><a href="#testing_urls_hyperlinking">TESTING URLs hyperlinking</a></li>
<li><a href="#see_also">SEE ALSO</a></li>
</ul>
<!-- INDEX END -->
<hr />
<p>
</p>
<h1><a name="name">NAME</a></h1>
<p>Test HTML Rendering</p>
<p>
</p>
<hr />
<h1><a name="synopsis">SYNOPSIS</a></h1>
<pre>
use My::Module;</pre>
<pre>
my $module = My::Module->new();</pre>
<p>
</p>
<hr />
<h1><a name="description">DESCRIPTION</a></h1>
<p>This is the description.</p>
<pre>
Here is a verbatim section.</pre>
<p>This is some more regular text.</p>
<p>Here is some <strong>bold</strong> text, some <em>italic</em> and something that looks
like an <html> tag. This is some <code>$code($arg1)</code>.</p>
<p>This <code>text contains embedded bold and italic tags</code>. These can
be nested, allowing <strong>bold and <em>bold & italic</em> text</strong>. The module also
supports the extended <strong>syntax </strong>> and permits <em>nested tags &
other <strong>cool </strong></em>> stuff >></p>
<p>
</p>
<hr />
<h1><a name="methods____other_stuff">METHODS => OTHER STUFF</a></h1>
<p>Here is a list of methods</p>
<p>
</p>
<h2><a name="new__"><code>new()</code></a></h2>
<p>Constructor method. Accepts the following config options:</p>
<dl>
<dt><strong><a name="item_foo">foo</a></strong>
<dd>
<p>The foo item.</p>
</dd>
</li>
<dt><strong><a name="item_bar">bar</a></strong>
<dd>
<p>The bar item.</p>
</dd>
<p>This is a list within a list</p>
<ul>
<li>
<p>The wiz item.</p>
</li>
<li>
<p>The waz item.</p>
</li>
</ul>
<dt><strong><a name="item_baz">baz</a></strong>
<dd>
<p>The baz item.</p>
</dd>
</li>
</dl>
<p>Title on the same line as the =item + * bullets</p>
<ul>
<li><strong><a name="item_black_cat"><code>Black</code> Cat</a></strong>
<li><strong><a name="item_sat_on_the">Sat <em>on</em> the</a></strong>
<li><strong><a name="item_mat_3c_21_3e">Mat<!></a></strong>
</ul>
<p>Title on the same line as the =item + numerical bullets</p>
<ol>
<li><strong><a name="item_cat">Cat</a></strong>
<li><strong><a name="item_sat">Sat</a></strong>
<li><strong><a name="item_mat">Mat</a></strong>
</ol>
<p>No bullets, no title</p>
<dl>
<dt>
<dd>
<p>Cat</p>
</dd>
</li>
<dt>
<dd>
<p>Sat</p>
</dd>
</li>
<dt>
<dd>
<p>Mat</p>
</dd>
</li>
</dl>
<p>
</p>
<h2><a name="old__"><code>old()</code></a></h2>
<p>Destructor method</p>
<p>
</p>
<hr />
<h1><a name="testing_for_and_begin">TESTING FOR AND BEGIN</a></h1>
<br>
<p>
blah blah
</p><p>intermediate text</p>
<more>
HTML
</more>some text<p>
</p>
<hr />
<h1><a name="testing_urls_hyperlinking">TESTING URLs hyperlinking</a></h1>
<p>This is an href link1: <a href="http://example.com">http://example.com</a></p>
<p>This is an href link2: <a href="http://example.com/foo/bar.html">http://example.com/foo/bar.html</a></p>
<p>This is an email link: <a href="mailto:mailto:foo at bar.com">mailto:foo at bar.com</a></p>
<pre>
This is a link in a verbatim block <a href="<a href="http://perl.org">http://perl.org</a>"> Perl </a></pre>
<p>
</p>
<hr />
<h1><a name="see_also">SEE ALSO</a></h1>
<p>See also <a href="/t/htmlescp.html">Test Page 2</a>, the <a href="/Your/Module.html">the Your::Module manpage</a> and <a href="/Their/Module.html">the Their::Module manpage</a>
manpages and the other interesting file <em>/usr/local/my/module/rocks</em>
as well.</p>
</body>
</html>
--- NEW FILE: htmlescp.t ---
#!/usr/bin/perl -w # -*- perl -*-
BEGIN {
chdir 't' if -d 't';
unshift @INC, '../lib';
unshift @INC, '../lib/Pod/t';
require "pod2html-lib.pl";
}
use strict;
use Test::More tests => 1;
convert_n_test("htmlescp", "html escape");
__DATA__
<?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>NAME</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rev="made" href="mailto:[PERLADMIN]" />
</head>
<body style="background-color: white">
<p><a name="__index__"></a></p>
<!-- INDEX BEGIN -->
<ul>
<li><a href="#name">NAME</a></li>
<li><a href="#description">DESCRIPTION</a></li>
</ul>
<!-- INDEX END -->
<hr />
<p>
</p>
<h1><a name="name">NAME</a></h1>
<p>Escape Sequences Test</p>
<p>
</p>
<hr />
<h1><a name="description">DESCRIPTION</a></h1>
<p>I am a stupid fool who puts naked < & > characters in my POD
instead of escaping them as < and >.</p>
<p>Here is some <strong>bold</strong> text, some <em>italic</em> plus <em>/etc/fstab</em>
file and something that looks like an <html> tag.
This is some <code>$code($arg1)</code>.</p>
</body>
</html>
--- NEW FILE: htmlview.pod ---
=head1 NAME
Test HTML Rendering
=head1 SYNOPSIS
use My::Module;
my $module = My::Module->new();
=head1 DESCRIPTION
This is the description.
Here is a verbatim section.
This is some more regular text.
Here is some B<bold> text, some I<italic> and something that looks
like an E<lt>htmlE<gt> tag. This is some C<$code($arg1)>.
This C<text contains embedded B<bold> and I<italic> tags>. These can
be nested, allowing B<bold and I<bold E<amp> italic> text>. The module also
supports the extended B<< syntax >> and permits I<< nested tags E<amp>
other B<<< cool >>> stuff >>
=head1 METHODS =E<gt> OTHER STUFF
Here is a list of methods
=head2 new()
Constructor method. Accepts the following config options:
=over 4
=item foo
The foo item.
=item bar
The bar item.
=over 4
This is a list within a list
=item *
The wiz item.
=item *
The waz item.
=back
=item baz
The baz item.
=back
Title on the same line as the =item + * bullets
=over
=item * C<Black> Cat
=item * Sat S<I<on> the>
=item * MatE<lt>!E<gt>
=back
Title on the same line as the =item + numerical bullets
=over
=item 1 Cat
=item 2 Sat
=item 3 Mat
=back
No bullets, no title
=over
=item
Cat
=item
Sat
=item
Mat
=back
=head2 old()
Destructor method
=head1 TESTING FOR AND BEGIN
=for html <br>
<p>
blah blah
</p>
intermediate text
=begin html
<more>
HTML
</more>
some text
=end html
=head1 TESTING URLs hyperlinking
This is an href link1: http://example.com
This is an href link2: http://example.com/foo/bar.html
This is an email link: mailto:foo at bar.com
This is a link in a verbatim block <a href="http://perl.org"> Perl </a>
=head1 SEE ALSO
See also L<Test Page 2|htmlescp>, the L<Your::Module> and L<Their::Module>
manpages and the other interesting file F</usr/local/my/module/rocks>
as well.
=cut
--- NEW FILE: basic.man ---
.SH "NAME"
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
other interesting bits.
.ie n .SH "This ""is"" a ""level 1"" heading"
.el .SH "This \f(CWis\fP a ``level 1'' heading"
.IX Header "This is a level 1 heading"
.Sh "``Level'' ""2 \fIheading\fP"
.IX Subsection "``Level'' ""2 heading"
\fILevel 3 \f(BIheading \f(BIwith \f(CB\*(C`weird \f(CBstuff "" (double quote)\f(CB\*(C'\f(BI\f(BI\fI\fR
.IX Subsection "Level 3 heading with weird stuff """" (double quote)"
.PP
Level "4 \f(CW\*(C`heading\*(C'\fR
.IX Subsection "Level ""4 heading"
.PP
Now try again with \fBintermixed\fR \fItext\fR.
.ie n .SH "This ""is"" a ""level 1"" heading"
.el .SH "This \f(CWis\fP a ``level 1'' heading"
.IX Header "This is a level 1 heading"
Text.
.Sh "``Level'' 2 \fIheading\fP"
.IX Subsection "``Level'' 2 heading"
Text.
.PP
\fILevel 3 \f(BIheading \f(BIwith \f(CB\*(C`weird \f(CBstuff\f(CB\*(C'\f(BI\f(BI\fI\fR
.IX Subsection "Level 3 heading with weird stuff"
.PP
Text.
.PP
Level "4 \f(CW\*(C`heading\*(C'\fR
.IX Subsection "Level ""4 heading"
.PP
Text.
.SH "LINKS"
.IX Header "LINKS"
These are all taken from the Pod::Parser tests.
.PP
Try out \fI\s-1LOTS\s0\fR of different ways of specifying references:
.PP
Reference the \*(L"section\*(R" in manpage
.PP
Reference the \*(L"section\*(R" in manpage
.PP
Reference the \*(L"section\*(R" in manpage
.PP
Reference the \*(L"section\*(R" in manpage
.PP
Reference the \*(L"manpage/section\*(R"
.PP
Reference the \*(L"section\*(R" in \*(L"manpage\*(R"
.PP
Reference the \*(L"section\*(R" in manpage
.PP
Reference the \*(L"section\*(R" in manpage
.PP
Reference the \*(L"section\*(R" in manpage
.PP
Now try it using the new \*(L"|\*(R" stuff ...
.PP
Reference the thistext|
.PP
Reference the thistext |
.PP
Reference the thistext|
.PP
Reference the thistext |
.PP
Reference the thistext|
.PP
Reference the thistext |
.PP
Reference the thistext|
.PP
Reference the thistext|
.PP
Reference the thistext |
.PP
And then throw in a few new ones of my own.
.PP
foo
.PP
foo
.PP
\&\*(L"bar\*(R" in foo
.PP
\&\*(L"baz boo\*(R" in foo
.PP
\&\*(L"bar\*(R"
.PP
\&\*(L"baz boo\*(R"
.PP
\&\*(L"baz boo\*(R"
.PP
\&\*(L"baz boo\*(R" in foo bar
.PP
\&\*(L"baz boo\*(R" in foo bar
.PP
\&\*(L"boo\*(R" in foo bar baz
.PP
\&\*(L"boo var baz\*(R"
.PP
\&\*(L"bar baz\*(R"
.PP
\&\*(L"boo bar baz / baz boo\*(R"
.PP
\&\*(L"boo\*(R", \*(L"bar\*(R", and \*(L"baz\*(R"
.PP
foo\&bar
.PP
Testing \fIitalics\fR
.PP
"\fIItalic\fR text" in foo
.PP
"Section \f(CW\*(C`with\*(C'\fR \fI\f(BIother\fI markup\fR" in foo|bar\&
.PP
Nested <http://www.perl.org/>
.SH "OVER AND ITEMS"
.IX Header "OVER AND ITEMS"
Taken from Pod::Parser tests, this is a test to ensure that multiline
=item paragraphs get indented appropriately.
.IP "This is a test." 4
.IX Item "This is a test."
.PP
There should be whitespace now before this line.
.PP
Taken from Pod::Parser tests, this is a test to ensure the nested =item
paragraphs get indented appropriately.
.IP "1" 2
.IX Item "1"
First section.
.RS 2
.IP "a" 2
.IX Item "a"
this is item a
.IP "b" 2
.IX Item "b"
this is item b
.RE
.RS 2
.RE
.IP "2" 2
.IX Item "2"
Second section.
.RS 2
.IP "a" 2
.IX Item "a"
this is item a
.IP "b" 2
.IX Item "b"
this is item b
.IP "c" 2
.IX Item "c"
.PD 0
.IP "d" 2
.IX Item "d"
.PD
This is item c & d.
.RE
.RS 2
.RE
.PP
Now some additional weirdness of our own. Make sure that multiple tags
for one paragraph are properly compacted.
.ie n .IP """foo""" 4
.el .IP "``foo''" 4
.IX Item "foo"
.PD 0
.IP "\fBbar\fR" 4
.IX Item "bar"
.ie n .IP """baz""" 4
.el .IP "\f(CWbaz\fR" 4
.IX Item "baz"
.PD
There shouldn't be any spaces between any of these item tags; this idiom
is used in perlfunc.
.IP "Some longer item text" 4
.IX Item "Some longer item text"
Just to make sure that we test paragraphs where the item text doesn't fit
in the margin of the paragraph (and make sure that this paragraph fills a
few lines).
.Sp
Let's also make it multiple paragraphs to be sure that works.
.PP
Test use of =over without =item as a block \*(L"quote\*(R" or block paragraph.
.Sp
.RS 4
This should be indented four spaces but otherwise formatted the same as
any other regular text paragraph. Make sure it's long enough to see the
results of the formatting.....
.RE
.PP
Now try the same thing nested, and make sure that the indentation is reset
back properly.
.RS 4
.Sp
.RS 4
This paragraph should be doubly indented.
.RE
.RE
.RS 4
.Sp
This paragraph should only be singly indented.
.IP "\(bu" 4
This is an item in the middle of a block\-quote, which should be allowed.
.IP "\(bu" 4
We're also testing tagless item commands.
.RE
.RS 4
.Sp
Should be back to the single level of indentation.
.RE
.PP
Should be back to regular indentation.
.PP
Now also check the transformation of * into real bullets for man pages.
.IP "\(bu" 4
An item. We're also testing using =over without a number, and making sure
that item text wraps properly.
.IP "\(bu" 4
Another item.
.PP
and now test the numbering of item blocks.
.IP "1." 4
First item.
.IP "2." 4
Second item.
.SH "FORMATTING CODES"
.IX Header "FORMATTING CODES"
Another test taken from Pod::Parser.
.PP
This is a test to see if I can do not only \f(CW$self\fR and \f(CW\*(C`method()\*(C'\fR, but
also \f(CW\*(C`$self\->method()\*(C'\fR and \f(CW\*(C`$self\->{FIELDNAME}\*(C'\fR and
\&\f(CW\*(C`$Foo <=> $Bar\*(C'\fR without resorting to escape sequences. If
I want to refer to the right-shift operator I can do something
like \f(CW\*(C`$x >> 3\*(C'\fR or even \f(CW\*(C`$y >> 5\*(C'\fR.
.PP
Now for the grand finale of \f(CW\*(C`$self\->method()\->{FIELDNAME} = {FOO=>BAR}\*(C'\fR.
And I also want to make sure that newlines work like this
\&\f(CW\*(C`$self\->{FOOBAR} >> 3 and [$b => $a]\->[$a <=> $b]\*(C'\fR
.PP
Of course I should still be able to do all this \fIwith\fR escape sequences
too: \f(CW\*(C`$self\->method()\*(C'\fR and \f(CW\*(C`$self\->{FIELDNAME}\*(C'\fR and
\&\f(CW\*(C`{FOO=>BAR}\*(C'\fR.
.PP
Dont forget \f(CW\*(C`$self\->method()\->{FIELDNAME} = {FOO=>BAR}\*(C'\fR.
.PP
And make sure that \f(CW0\fR works too!
.PP
Now, if I use << or >> as my delimiters, then I have to use whitespace.
So things like \f(CW\*(C`<$self\-\*(C'\fR\fImethod()\fR>> and \f(CW\*(C`<$self\-\*(C'\fR{\s-1FIELDNAME\s0}>> wont end
up doing what you might expect since the first > will still terminate
the first < seen.
.PP
Lets make sure these work for empty ones too, like and \f(CW\*(C`>>\*(C'\fR
(just to be obnoxious)
.PP
The statement: \f(CW\*(C`This is dog kind's \f(CIfinest\f(CW hour!\*(C'\fR is a parody of a
quotation from Winston Churchill.
.PP
The following tests are added to those:
.PP
Make sure that a few oth\&er odd \fI\&things\fR still work. This should be
a vertical bar: |. Here's a test of a few more special escapes
that have to be supported:
.IP "&" 3
An ampersand.
.IP "'" 3
An apostrophe.
.IP "<" 3
A less-than sign.
.IP ">" 3
A greater-than sign.
.IP """" 3
A double quotation mark.
.IP "/" 3
A forward slash.
.PP
Try to get this bit of text over towards the edge so |that\ all\ of\ this\ text\ inside\ S<>\ won't| be wrapped. Also test the
|same\ thing\ with\ non-breaking\ spaces.|
.PP
There is a soft hyphen in hyphen at hy\-phen.
.PP
This is a test of an index entry.
.IX Xref "index entry"
.SH "VERBATIM"
.IX Header "VERBATIM"
Throw in a few verbatim paragraphs.
.PP
.Vb 8
\& use Term::ANSIColor;
\& print color 'bold blue';
\& print "This text is bold blue.\en";
\& print color 'reset';
\& print "This text is normal.\en";
\& print colored ("Yellow on magenta.\en", 'yellow on_magenta');
\& 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
.Vb 2
\& 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
\& Starting with a tab.
\&Not
\&starting
\&with
\&a
\&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!
--- NEW FILE: Select.t ---
#!perl
use warnings;
use strict;
BEGIN {
chdir 't' if -d 't';
@INC = '../lib';
};
use Test::More tests => 9;
require_ok( 'Pod::Select' );
my $fake_out = tie *FAKEOUT, 'CatchOut';
my $p_s = Pod::Select->new;
isa_ok( $p_s, 'Pod::Select' );
my $pod = << 'EO_NAME';
=head1 NAME
Select.t - Tests for Pod::Select.
EO_NAME
$p_s->select( 'NAME' );
$p_s->parse_from_file( $0, \*FAKEOUT );
is( $$fake_out, $pod, 'select( NAME )' );
$pod .= << 'EO_SYNOPSIS';
=head1 SYNOPSIS
This program just tests the basics of the Pod::Select module.
EO_SYNOPSIS
$$fake_out = '';
$p_s->select( 'NAME', 'SYNOPSIS' );
$p_s->parse_from_file( $0, \*FAKEOUT );
is( $$fake_out, $pod, 'select( NAME, SYNOPSIS )' );
$pod .= << 'EO_AUTHOR';
=head1 AUTHOR
Abe Timmerman <abe at ztreet.demon.nl>
EO_AUTHOR
$$fake_out = '';
$p_s->add_selection( 'AUTHOR' );
$p_s->parse_from_file( $0, \*FAKEOUT );
is( $$fake_out, $pod, 'add_selection( AUTHOR )' );
my $head1 = $p_s->curr_headings(1);
is( $head1, 'AUTHOR', 'curr_headings()' );
$pod = << 'EO_DESCRIPTION';
=head2 subsection
a sub-section can be specified
EO_DESCRIPTION
$$fake_out = '';
$p_s->select( 'DESCRIPTION/subsection' );
$p_s->parse_from_file( $0, \*FAKEOUT );
is( $$fake_out, $pod, 'select( DESCRIPTION/subsection )' );
ok( $p_s->match_section( 'DESCRIPTION', 'subsection' ),
'match_section( DESCRIPTION, subsection )' );
$pod = << 'EO_DESCRIPTION';
=head1 DESCRIPTION
I'll go by the POD in Pod::Select.
EO_DESCRIPTION
$$fake_out = '';
$p_s->select( 'DESCRIPTION/!.+' );
$p_s->parse_from_file( $0, \*FAKEOUT );
is( $$fake_out, $pod, 'select( DESCRIPTION/!.+ )' );
package CatchOut;
sub TIEHANDLE { bless \( my $self ), shift }
sub PRINT { my $self = shift; $$self .= $_[0] }
__END__
=head1 NAME
Select.t - Tests for Pod::Select.
=head1 SYNOPSIS
This program just tests the basics of the Pod::Select module.
=head1 DESCRIPTION
I'll go by the POD in Pod::Select.
=head2 selection + add_selection
Pull out the specified sections
=head2 subsection
a sub-section can be specified
=head1 AUTHOR
Abe Timmerman <abe at ztreet.demon.nl>
=cut
--- NEW FILE: text-options.t ---
#!/usr/bin/perl -w
# $Id: text-options.t,v 1.1 2006-12-04 17:00:58 dslinux_cayenne Exp $
#
# text-options.t -- Additional tests for Pod::Text options.
#
# Copyright 2002 by Russ Allbery <rra at 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..3\n";
}
END {
print "not ok 1\n" unless $loaded;
}
use Pod::Text;
$loaded = 1;
print "ok 1\n";
my $n = 2;
while (<DATA>) {
my %options;
next until $_ eq "###\n";
while (<DATA>) {
last if $_ eq "###\n";
my ($option, $value) = split;
$options{$option} = $value;
}
open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n";
while (<DATA>) {
last if $_ eq "###\n";
print TMP $_;
}
close TMP;
my $parser = Pod::Text->new (%options) 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";
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 text output.
# This is used to test specific features or problems with Pod::Text. The
# input and output are separated by lines containing only ###.
__DATA__
###
alt 1
###
=head1 SAMPLE
=over 4
=item F
Paragraph.
=item Bar
=item B
Paragraph.
=item Longer
Paragraph.
=back
###
==== SAMPLE ====
: F Paragraph.
: Bar
: B Paragraph.
: Longer
Paragraph.
###
###
margin 4
###
=head1 SAMPLE
This is some body text that is long enough to be a paragraph that wraps,
thereby testing margins with wrapped paragraphs.
This is some verbatim text.
=over 6
=item Test
This is a test of an indented paragraph.
This is another indented paragraph.
=back
###
SAMPLE
This is some body text that is long enough to be a paragraph that
wraps, thereby testing margins with wrapped paragraphs.
This is some verbatim text.
Test This is a test of an indented paragraph.
This is another indented paragraph.
###
--- NEW FILE: htmllink.pod ---
=head1 NAME
htmllink - Test HTML links
=head1 LINKS
L</"section1">
L</"section 2">
L</"section three">
L</"item1">
L</"item 2">
L</"item three">
L</section1>
L</section 2>
L</section three>
L</item1>
L</item 2>
L</item three>
L<"section1">
L<"section 2">
L<"section three">
L<"item1">
L<"item 2">
L<"item three">
L<text|/"section1">
L<text|/"section 2">
L<text|/"section three">
L<text|/"item1">
L<text|/"item 2">
L<text|/"item three">
L<text|/section1>
L<text|/section 2>
L<text|/section three>
L<text|/item1>
L<text|/item 2>
L<text|/item three>
L<text|"section1">
L<text|"section 2">
L<text|"section three">
L<text|"item1">
L<text|"item 2">
L<text|"item three">
=head1 TARGETS
=head2 section1
This is section one.
=head2 section 2
This is section two.
=head2 section three
This is section three.
=over 4
=item item1
This is item one.
=item item 2
This is item two.
=item item three
This is item three.
=back
--- NEW FILE: basic.txt ---
NAME
basic.pod - Test of various basic POD features in translators.
HEADINGS
Try a few different levels of headings, with embedded formatting codes
and other interesting bits.
This "is" a "level 1" heading
``Level'' "2 *heading*
Level 3 heading *with "weird stuff "" (double quote)"*
Level "4 "heading"
Now try again with intermixed text.
This "is" a "level 1" heading
Text.
``Level'' 2 *heading*
Text.
Level 3 heading *with "weird stuff"*
Text.
Level "4 "heading"
Text.
LINKS
These are all taken from the Pod::Parser tests.
Try out *LOTS* of different ways of specifying references:
Reference the "section" in manpage
Reference the "section" in manpage
Reference the "section" in manpage
Reference the "section" in manpage
Reference the "manpage/section"
Reference the "section" in "manpage"
Reference the "section" in manpage
Reference the "section" in manpage
Reference the "section" in manpage
Now try it using the new "|" stuff ...
Reference the thistext|
Reference the thistext |
Reference the thistext|
Reference the thistext |
Reference the thistext|
Reference the thistext |
Reference the thistext|
Reference the thistext|
Reference the thistext |
And then throw in a few new ones of my own.
foo
foo
"bar" in foo
"baz boo" in foo
"bar"
"baz boo"
"baz boo"
"baz boo" in foo bar
"baz boo" in foo bar
"boo" in foo bar baz
"boo var baz"
"bar baz"
"boo bar baz / baz boo"
"boo", "bar", and "baz"
foobar
Testing *italics*
"*Italic* text" in foo
"Section "with" *other markup*" in foo|bar
Nested <http://www.perl.org/>
OVER AND ITEMS
Taken from Pod::Parser tests, this is a test to ensure that multiline
=item paragraphs get indented appropriately.
This is a test.
There should be whitespace now before this line.
Taken from Pod::Parser tests, this is a test to ensure the nested =item
paragraphs get indented appropriately.
1 First section.
a this is item a
b this is item b
2 Second section.
a this is item a
b this is item b
c
d This is item c & d.
Now some additional weirdness of our own. Make sure that multiple tags
for one paragraph are properly compacted.
"foo"
bar
"baz"
There shouldn't be any spaces between any of these item tags; this
idiom is used in perlfunc.
Some longer item text
Just to make sure that we test paragraphs where the item text
doesn't fit in the margin of the paragraph (and make sure that this
paragraph fills a few lines).
Let's also make it multiple paragraphs to be sure that works.
Test use of =over without =item as a block "quote" or block paragraph.
This should be indented four spaces but otherwise formatted the same
as any other regular text paragraph. Make sure it's long enough to
see the results of the formatting.....
Now try the same thing nested, and make sure that the indentation is
reset back properly.
This paragraph should be doubly indented.
This paragraph should only be singly indented.
* This is an item in the middle of a block-quote, which should be
allowed.
* We're also testing tagless item commands.
Should be back to the single level of indentation.
Should be back to regular indentation.
Now also check the transformation of * into real bullets for man pages.
* An item. We're also testing using =over without a number, and making
sure that item text wraps properly.
* Another item.
and now test the numbering of item blocks.
1. First item.
2. Second item.
FORMATTING CODES
Another test taken from Pod::Parser.
This is a test to see if I can do not only $self and "method()", but
also "$self->method()" and "$self->{FIELDNAME}" and "$Foo <=> $Bar"
without resorting to escape sequences. If I want to refer to the
right-shift operator I can do something like "$x >> 3" or even "$y >>
5".
Now for the grand finale of "$self->method()->{FIELDNAME} = {FOO=>BAR}".
And I also want to make sure that newlines work like this
"$self->{FOOBAR} >> 3 and [$b => $a]->[$a <=> $b]"
Of course I should still be able to do all this *with* escape sequences
too: "$self->method()" and "$self->{FIELDNAME}" and "{FOO=>BAR}".
Dont forget "$self->method()->{FIELDNAME} = {FOO=>BAR}".
And make sure that 0 works too!
Now, if I use << or >> as my delimiters, then I have to use whitespace.
So things like "<$self-"method()>> and "<$self-"{FIELDNAME}>> wont end
up doing what you might expect since the first > will still terminate
the first < seen.
Lets make sure these work for empty ones too, like and ">>" (just to be
obnoxious)
The statement: "This is dog kind's *finest* hour!" is a parody of a
quotation from Winston Churchill.
The following tests are added to those:
Make sure that a few other odd *things* still work. This should be a
vertical bar: |. Here's a test of a few more special escapes that have
to be supported:
& An ampersand.
' An apostrophe.
< A less-than sign.
> A greater-than sign.
" A double quotation mark.
/ A forward slash.
Try to get this bit of text over towards the edge so
|that all of this text inside S<> won't| be wrapped. Also test the
|same thing with non-breaking spaces.|
There is a soft hyphen in hyphen at hy-phen.
This is a test of an index entry.
VERBATIM
Throw in a few verbatim paragraphs.
use Term::ANSIColor;
print color 'bold blue';
print "This text is bold blue.\n";
print color 'reset';
print "This text is normal.\n";
print colored ("Yellow on magenta.\n", 'yellow on_magenta');
print "This text is normal.\n";
print colored ['yellow on_magenta'], "Yellow on magenta.\n";
use Term::ANSIColor qw(uncolor);
print uncolor '01;31', "\n";
But this isn't verbatim (make sure it wraps properly), and the next
paragraph is again:
use Term::ANSIColor qw(:constants);
print BOLD, BLUE, "This text is in bold blue.\n", RESET;
use Term::ANSIColor qw(:constants); $Term::ANSIColor::AUTORESET = 1; print BOLD BLUE "This text is in bold blue.\n"; print "This text is normal.\n";
(Ugh, that's obnoxiously long.) Try different spacing:
Starting with a tab.
Not
starting
with
a
tab. But this should still be verbatim.
As should this.
This isn't.
This is. And this: is an internal tab. It should be:
|--| <= lined up with that.
(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.)
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!
--- NEW FILE: eol.t ---
#!./perl -w
use Test::More tests => 3;
open(POD, ">$$.pod") or die "$$.pod: $!";
print POD <<__EOF__;
=pod
=head1 NAME
crlf
=head1 DESCRIPTION
crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf
crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf
crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf
crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf
crlf crlf crlf crlf
crlf crlf crlf crlf
crlf crlf crlf crlf
crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf
crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf
crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf
crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf
=cut
__EOF__
close(POD);
use Pod::Html;
# --- CR ---
open(POD, "<$$.pod") or die "$$.pod: $!";
open(IN, ">$$.in") or die "$$.in: $!";
while (<POD>) {
s/[\r\n]+/\r/g;
print IN $_;
}
close(POD);
close(IN);
pod2html("--title=eol", "--infile=$$.in", "--outfile=$$.o1");
# --- LF ---
open(POD, "<$$.pod") or die "$$.pod: $!";
open(IN, ">$$.in") or die "$$.in: $!";
while (<POD>) {
s/[\r\n]+/\n/g;
print IN $_;
}
close(POD);
close(IN);
pod2html("--title=eol", "--infile=$$.in", "--outfile=$$.o2");
# --- CRLF ---
open(POD, "<$$.pod") or die "$$.pod: $!";
open(IN, ">$$.in") or die "$$.in: $!";
while (<POD>) {
s/[\r\n]+/\r\n/g;
print IN $_;
}
close(POD);
close(IN);
pod2html("--title=eol", "--infile=$$.in", "--outfile=$$.o3");
# --- now test ---
local $/;
open(IN, "<$$.o1") or die "$$.o1: $!";
my $cksum1 = unpack("%32C*", <IN>);
open(IN, "<$$.o2") or die "$$.o2: $!";
my $cksum2 = unpack("%32C*", <IN>);
open(IN, "<$$.o3") or die "$$.o3: $!";
my $cksum3 = unpack("%32C*", <IN>);
ok($cksum1 == $cksum2, "CR vs LF");
ok($cksum1 == $cksum3, "CR vs CRLF");
ok($cksum2 == $cksum3, "LF vs CRLF");
close IN;
END {
1 while unlink("$$.pod", "$$.in", "$$.o1", "$$.o2", "$$.o3",
"pod2htmd.x~~", "pod2htmi.x~~");
}
--- NEW FILE: InputObjects.t ---
#!perl -Tw
BEGIN {
chdir 't' if -d 't';
@INC = '../lib';
}
use Test::More;
plan tests => 33;
use_ok( 'Pod::InputObjects' );
{ # test package Pod::InputSource
local *FH;
my $p_is = Pod::InputSource->new( -handle => \*FH );
isa_ok( $p_is, 'Pod::InputSource', 'Pod::InputSource constructor' );
is( $p_is->name, '(unknown)', 'Pod::InputSource->name()' );
is( $p_is->name( 'test' ), 'test', 'set Pod::InputSource->name( test )' );
is( $p_is->filename, 'test', 'Pod::InputSource->filename() alias' );
is( $p_is->handle, \*FH, 'Pod::InputSource->handle()' );
is( $p_is->was_cutting(), 0, 'Pod::InputSource->was_cutting()' );
is( $p_is->was_cutting( 1 ), 1, 'set Pod::InputSource->was_cutting( 1 )' );
}
{ # test package Pod::Paragraph
my $p_p1 = Pod::Paragraph->new( -text => 'NAME', -name => 'head2' );
my $p_p2 = Pod::Paragraph->new( 'test - This is the test suite' );
isa_ok( $p_p1, 'Pod::Paragraph', 'Pod::Paragraph constuctor' );
isa_ok( $p_p2, 'Pod::Paragraph', 'Pod::Paragraph constructor revisited' );
is( $p_p1->cmd_name(), 'head2', 'Pod::Paragraph->cmd_name()' );
is( $p_p1->cmd_name( 'head1' ), 'head1',
'Pod::Paragraph->cmd_name( head1 )' );
ok( !$p_p2->cmd_name(),
'Pod::Paragraph->cmd_name() revisited' );
is( $p_p1->text(), 'NAME', 'Pod::Paragraph->text()' );
is( $p_p2->text(), 'test - This is the test suite',
'Pod::Paragraph->text() revisited' );
my $new_text = 'test - This is the test suite.';
is( $p_p2->text( $new_text ), $new_text,
'Pod::Paragraph->text( ... )' );
is( $p_p1->raw_text, '=head1 NAME',
'Pod::Paragraph->raw_text()' );
is( $p_p2->raw_text, $new_text,
'Pod::Paragraph->raw_text() revisited' );
is( $p_p1->cmd_prefix, '=',
'Pod::Paragraph->cmd_prefix()' );
is( $p_p1->cmd_separator, ' ',
'Pod::Paragraph->cmd_separator()' );
# Pod::Parser->parse_tree() / ptree()
is( $p_p1->file_line(), '<unknown-file>:0',
'Pod::Paragraph->file_line()' );
$p_p2->{ '-file' } = 'test'; $p_p2->{ '-line' } = 3;
is( $p_p2->file_line(), 'test:3',
'Pod::Paragraph->file_line()' );
}
{ # test package Pod::InteriorSequence
my $p_pt = Pod::ParseTree->new();
my $pre_txt = 'test - This is the ';
my $cmd_txt = 'test suite';
my $pst_txt ='.';
$p_pt->append( $cmd_txt );
my $p_is = Pod::InteriorSequence->new(
-name => 'I', -ldelim => '<', -rdelim => '>',
-ptree => $p_pt
);
isa_ok( $p_is, 'Pod::InteriorSequence', 'P::InteriorSequence constructor' );
is( $p_is->cmd_name(), 'I', 'Pod::InteriorSequence->cmd_name()' );
is( $p_is->cmd_name( 'B' ), 'B',
'set Pod::InteriorSequence->cmd_name( B )' );
is( $p_is->raw_text(), "B<$cmd_txt>",
'Pod::InteriorSequence->raw_text()' );
$p_is->prepend( $pre_txt );
is( $p_is->raw_text(), "B<$pre_txt$cmd_txt>",
'raw_text() after prepend()' );
$p_is->append( $pst_txt );
is( $p_is->raw_text(), "B<$pre_txt$cmd_txt$pst_txt>",
'raw_text() after append()' );
}
{ # test package Pod::ParseTree
my $p_pt1 = Pod::ParseTree->new();
my $p_pt2 = Pod::ParseTree->new();
isa_ok( $p_pt1, 'Pod::ParseTree',
'Pod::ParseTree constructor' );
is( $p_pt1->top(), $p_pt1, 'Pod::ParseTree->top()' );
is( $p_pt1->top( $p_pt1, $p_pt2 ), $p_pt1,
'set new Pod::ParseTree->top()' );
ok( eq_array( [ $p_pt1->children() ], [ $p_pt1, $p_pt2] ),
'Pod::ParseTree->children()' );
my $text = 'This is the test suite.';
$p_pt2->append( $text );
is( $p_pt2->raw_text(), $text, 'Pod::ParseTree->append()' );
}
__END__
=head1 NAME
InputObjects.t - The tests for Pod::InputObjects
=head AUTHOR
20011220 Abe Timmerman <abe at ztreet.demon.nl>
=cut
--- NEW FILE: Functions.t ---
#!perl
BEGIN {
chdir 't' if -d 't';
@INC = '../lib';
}
use File::Basename;
use File::Spec;
use Test::More;
plan tests => 9;
use_ok( 'Pod::Functions' );
# How do you test exported vars?
my( $pkg_ref, $exp_ref ) = ( \%Pod::Functions::Kinds, \%Kinds );
is( $pkg_ref, $exp_ref, '%Pod::Functions::Kinds exported' );
( $pkg_ref, $exp_ref ) = ( \%Pod::Functions::Type, \%Type );
is( $pkg_ref, $exp_ref, '%Pod::Functions::Type exported' );
( $pkg_ref, $exp_ref ) = ( \%Pod::Functions::Flavor, \%Flavor );
is( $pkg_ref, $exp_ref, '%Pod::Functions::Flavor exported' );
( $pkg_ref, $exp_ref ) = ( \%Pod::Functions::Type_Description,
\%Type_Description );
is( $pkg_ref, $exp_ref, '%Pod::Functions::Type_Description exported' );
( $pkg_ref, $exp_ref ) = ( \@Pod::Functions::Type_Order, \@Type_Order );
is( $pkg_ref, $exp_ref, '@Pod::Functions::Type_Order exported' );
# Check @Type_Order
my @catagories = qw(
String Regexp Math ARRAY LIST HASH I/O
Binary File Flow Namespace Misc Process Modules
Objects Socket SysV User Network Time
);
ok( eq_array( \@Type_Order, \@catagories ),
'@Type_Order' );
my @cat_keys = grep exists $Type_Description{ $_ } => @Type_Order;
ok( eq_array( \@cat_keys, \@catagories ),
'keys() %Type_Description' );
my( undef, $path ) = fileparse( $0 );
my $pod_functions = File::Spec->catfile(
$path, File::Spec->updir, 'Functions.pm' );
SKIP: {
my $test_out = do { local $/; <DATA> };
skip( "Can't fork '$^X': $!", 1)
unless open my $fh, qq[$^X "-I../lib" $pod_functions |];
my $fake_out = do { local $/; <$fh> };
skip( "Pipe error: $!", 1)
unless close $fh;
is( $fake_out, $test_out, 'run as plain program' );
}
=head1 NAME
Functions.t - Test Pod::Functions
=head1 AUTHOR
20011229 Abe Timmerman <abe at ztreet.demon.nl>
=cut
__DATA__
Functions for SCALARs or strings:
chomp, chop, chr, crypt, hex, index, lc, lcfirst, length,
oct, ord, pack, q/STRING/, qq/STRING/, reverse, rindex,
sprintf, substr, tr///, uc, ucfirst, y///
Regular expressions and pattern matching:
m//, pos, qr/STRING/, quotemeta, s///, split, study
Numeric functions:
abs, atan2, cos, exp, hex, int, log, oct, rand, sin, sqrt,
srand
Functions for real @ARRAYs:
pop, push, shift, splice, unshift
Functions for list data:
grep, join, map, qw/STRING/, reverse, sort, unpack
Functions for real %HASHes:
delete, each, exists, keys, values
Input and output functions:
binmode, close, closedir, dbmclose, dbmopen, die, eof,
fileno, flock, format, getc, print, printf, read, readdir,
readline, rewinddir, seek, seekdir, select, syscall,
sysread, sysseek, syswrite, tell, telldir, truncate, warn,
write
Functions for fixed length data or records:
pack, read, syscall, sysread, sysseek, syswrite, unpack,
vec
Functions for filehandles, files, or directories:
-X, chdir, chmod, chown, chroot, fcntl, glob, ioctl, link,
lstat, mkdir, open, opendir, readlink, rename, rmdir,
stat, symlink, sysopen, umask, unlink, utime
Keywords related to control flow of your perl program:
caller, continue, die, do, dump, eval, exit, goto, last,
next, prototype, redo, return, sub, wantarray
Keywords altering or affecting scoping of identifiers:
caller, import, local, my, our, package, use
Miscellaneous functions:
defined, dump, eval, formline, local, my, our, prototype,
reset, scalar, undef, wantarray
Functions for processes and process groups:
alarm, exec, fork, getpgrp, getppid, getpriority, kill,
pipe, qx/STRING/, readpipe, setpgrp, setpriority, sleep,
system, times, wait, waitpid
Keywords related to perl modules:
do, import, no, package, require, use
Keywords related to classes and object-orientedness:
bless, dbmclose, dbmopen, package, ref, tie, tied, untie,
use
Low-level socket functions:
accept, bind, connect, getpeername, getsockname,
getsockopt, listen, recv, send, setsockopt, shutdown,
socket, socketpair
System V interprocess communication functions:
msgctl, msgget, msgrcv, msgsnd, semctl, semget, semop,
shmctl, shmget, shmread, shmwrite
Fetching user and group info:
endgrent, endhostent, endnetent, endpwent, getgrent,
getgrgid, getgrnam, getlogin, getpwent, getpwnam,
getpwuid, setgrent, setpwent
Fetching network info:
endprotoent, endservent, gethostbyaddr, gethostbyname,
gethostent, getnetbyaddr, getnetbyname, getnetent,
getprotobyname, getprotobynumber, getprotoent,
getservbyname, getservbyport, getservent, sethostent,
setnetent, setprotoent, setservent
Time-related functions:
gmtime, localtime, time, times
--- NEW FILE: text-errors.t ---
#!/usr/bin/perl -w
# $Id: text-errors.t,v 1.1 2006-12-04 17:00:58 dslinux_cayenne Exp $
#
# texterrs.t -- Error tests for Pod::Text.
#
# Copyright 2001 by Russ Allbery <rra at 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++;
}
--- NEW FILE: basic.cap ---
(This appears to be a binary file; contents omitted.)
--- NEW FILE: basic.t ---
#!/usr/bin/perl -w
# $Id: basic.t,v 1.1 2006-12-04 17:00:58 dslinux_cayenne Exp $
#
# basic.t -- Basic tests for podlators.
#
# Copyright 2001 by Russ Allbery <rra at 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');
require Config;
if (($Config::Config{'extensions'} !~ /\bPOSIX\b/) ){
print "1..0 # Skip -- Perl configured without POSIX module\n";
exit 0;
}
$| = 1;
print "1..11\n";
}
END {
print "not ok 1\n" unless $loaded;
}
use Pod::Man;
use Pod::Text;
use Pod::Text::Color;
use Pod::Text::Overstrike;
use 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.
sub source_path {
my $file = shift;
if ($ENV{PERL_CORE}) {
require File::Spec;
my $updir = File::Spec->updir;
my $dir = File::Spec->catdir ($updir, 'lib', 'Pod', 't');
return File::Spec->catfile ($dir, $file);
} else {
return $file;
}
}
$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';
# Map of translators to file extensions to find the formatted output to
# compare against.
my %translators = ('Pod::Man' => 'man',
'Pod::Text' => 'txt',
'Pod::Text::Color' => 'clr',
'Pod::Text::Overstrike' => 'ovr',
'Pod::Text::Termcap' => 'cap');
# Set default options to match those of pod2man and pod2text.
%options = (sentence => 0);
my $n = 2;
for (sort keys %translators) {
my $parser = $_->new (%options);
print (($parser && ref ($parser) eq $_) ? "ok $n\n" : "not ok $n\n");
$n++;
# 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.
if ($_ eq 'Pod::Man') {
$parser->parse_from_file (source_path ('basic.pod'), 'out.tmp');
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 /^\.TH/ }
print OUTPUT while <TMP>;
close OUTPUT;
close TMP;
unlink 'out.tmp';
} else {
my $basic = source_path ('basic.pod');
$parser->parse_from_file ($basic, "out.$translators{$_}");
}
{
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;
# 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') {
$output =~ tr/\033/\047/;
}
if ($master eq $output) {
print "ok $n\n";
unlink "out.$translators{$_}";
} else {
print "not ok $n\n";
print "# Non-matching output left in out.$translators{$_}\n";
}
}
$n++;
}
--- NEW FILE: basic.clr ---
(This appears to be a binary file; contents omitted.)
--- NEW FILE: man.t ---
#!/usr/bin/perl -w
# $Id: man.t,v 1.1 2006-12-04 17:00:58 dslinux_cayenne Exp $
#
# man.t -- Additional specialized tests for Pod::Man.
#
# Copyright 2002, 2003 by Russ Allbery <rra at 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::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+.
###
###
=head1 PERIODS
This C<.> should be quoted.
###
.SH "PERIODS"
.IX Header "PERIODS"
This \f(CW\*(C`.\*(C'\fR should be quoted.
###
###
=over 4
=item *
A bullet.
=item *
Another bullet.
=item * Not a bullet.
=back
###
.IP "\(bu" 4
A bullet.
.IP "\(bu" 4
Another bullet.
.IP "* Not a bullet." 4
.IX Item "Not a bullet."
###
###
=over 4
=item foo
Not a bullet.
=item *
Also not a bullet.
=back
###
.IP "foo" 4
.IX Item "foo"
Not a bullet.
.IP "*" 4
Also not a bullet.
###
--- NEW FILE: user.t ---
#!perl
# Purpose: test UserPreamble and UserPostamble
# It's a minor variation of 'pod2latex.t',
# subject to the same limitations.
# Variant provided by
# Adriano Rodrigues Ferreira <ferreira at triang.com.br>
use Test;
use strict;
BEGIN { plan tests => 17 }
use Pod::LaTeX;
# The link parsing changed between v0.22 and v0.30 of Pod::ParseUtils
use Pod::ParseUtils;
my $linkver = $Pod::ParseUtils::VERSION;
# 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 = <DATA>) {
last if $line =~ /^=pod/;
push(@reference,$line);
}
my $user_preamble = <<PRE;
\\documentclass{article}
\\begin{document}
PRE
my $user_postamble = <<POST;
\\end{document}
POST
# Create a new parser
my %params = (
UserPreamble => $user_preamble,
UserPostamble => $user_postamble
);
my $parser = Pod::LaTeX->new(%params);
ok($parser);
# 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 = <INFH>;
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}
\begin{document}
%% Latex generated from POD in document (unknown)
%% Using the perl module Pod::LaTeX
%% Converted on Wed Jan 14 19:04:22 2004
%% Preamble supplied by user.
\section{POD\label{POD}\index{POD}}
This is a POD file, very simple. \textit{Bye}.
\end{document}
=pod
=head1 POD
This is a POD file, very simple. I<Bye>.
--- NEW FILE: text.t ---
#!/usr/bin/perl -w
# $Id: text.t,v 1.1 2006-12-04 17:00:58 dslinux_cayenne Exp $
#
# text.t -- Additional specialized tests for Pod::Text.
#
# Copyright 2002 by Russ Allbery <rra at 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::Text;
$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::Text->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";
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 text output.
# This is used to test specific features or problems with Pod::Text. The
# input and output are separated by lines containing only ###.
__DATA__
###
=head1 PERIODS
This C<.> should be quoted.
###
PERIODS
This "." should be quoted.
###
--- NEW FILE: htmlescp.pod ---
=head1 NAME
Escape Sequences Test
=head1 DESCRIPTION
I am a stupid fool who puts naked < & > characters in my POD
instead of escaping them as E<lt> and E<gt>.
Here is some B<bold> text, some I<italic> plus F</etc/fstab>
file and something that looks like an E<lt>htmlE<gt> tag.
This is some C<$code($arg1)>.
=cut
--- NEW FILE: utils.t ---
# Test hyperlinks et al from Pod::ParseUtils
BEGIN {
chdir 't' if -d 't';
@INC = '../lib';
require Test; import Test;
plan(tests => 22);
}
use strict;
use Pod::ParseUtils;
# First test the hyperlinks
my @links = qw{
name
name/ident
name/"sec"
"sec"
/"sec"
http://www.perl.org/
text|name
text|name/ident
text|name/"sec"
text|"sec"
};
my @results = (
"P<name>",
"Q<ident> in P<name>",
"Q<sec> in P<name>",
"Q<sec>",
"Q<sec>",
"Q<http://www.perl.org/>",
"Q<text>",
"Q<text>",
"Q<text>",
"Q<text>",
);
ok(@results, at links);
for my $i( 0.. at links ) {
my $link = new Pod::Hyperlink( $links[$i] );
ok($link->markup, $results[$i]);
}
# Now test lists
# This test needs to be better
my $list = new Pod::List( -indent => 4,
-start => 52,
-file => "itemtest.t",
-type => "OL",
);
ok($list);
ok($list->indent, 4);
ok($list->start, 52);
ok($list->type, "OL");
# Pod::Cache
# also needs work
my $cache = new Pod::Cache;
# Store it in the cache
$cache->item(
-page => "Pod::ParseUtils",
-description => "A description",
-file => "file.t",
);
# Now look for an item of this name
my $item = $cache->find_page("Pod::ParseUtils");
ok($item);
# and a failure
ok($cache->find_page("Junk"), undef);
# Make sure that the item we found is the same one as the
# first in the list
my @i = $cache->item;
ok($i[0], $item);
# Check the contents
ok($item->page, "Pod::ParseUtils");
ok($item->description, "A description");
ok($item->file, "file.t");
More information about the dslinux-commit
mailing list