diff options
author | Stas Bekman <stas@stason.org> | 2002-03-19 22:39:03 +0800 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2002-03-21 13:52:18 +0000 |
commit | 78343be7b86f9004a04a6659b6df1011666cda9e (patch) | |
tree | 8fa00cd559464b6499ad0ddcef16505299e9b87d /lib/Pod | |
parent | be32ca575491a02897628a19ea426507fca1e34e (diff) | |
download | perl-78343be7b86f9004a04a6659b6df1011666cda9e.tar.gz |
[tests for Pod::Html]
Message-ID: <Pine.LNX.4.44.0203191437360.25475-100000@hope.stason.org>
p4raw-id: //depot/perl@15383
Diffstat (limited to 'lib/Pod')
-rw-r--r-- | lib/Pod/t/htmlescp.pod | 14 | ||||
-rw-r--r-- | lib/Pod/t/htmlescp.t | 52 | ||||
-rw-r--r-- | lib/Pod/t/htmlview.pod | 144 | ||||
-rw-r--r-- | lib/Pod/t/htmlview.t | 175 | ||||
-rw-r--r-- | lib/Pod/t/pod2html-lib.pl | 37 |
5 files changed, 422 insertions, 0 deletions
diff --git a/lib/Pod/t/htmlescp.pod b/lib/Pod/t/htmlescp.pod new file mode 100644 index 0000000000..dc53ca75a0 --- /dev/null +++ b/lib/Pod/t/htmlescp.pod @@ -0,0 +1,14 @@ +=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 diff --git a/lib/Pod/t/htmlescp.t b/lib/Pod/t/htmlescp.t new file mode 100644 index 0000000000..b7913c505b --- /dev/null +++ b/lib/Pod/t/htmlescp.t @@ -0,0 +1,52 @@ +#!/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__ +<!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> +<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> diff --git a/lib/Pod/t/htmlview.pod b/lib/Pod/t/htmlview.pod new file mode 100644 index 0000000000..62ac71ced4 --- /dev/null +++ b/lib/Pod/t/htmlview.pod @@ -0,0 +1,144 @@ +=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@bar.com + +=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 diff --git a/lib/Pod/t/htmlview.t b/lib/Pod/t/htmlview.t new file mode 100644 index 0000000000..89634631f4 --- /dev/null +++ b/lib/Pod/t/htmlview.t @@ -0,0 +1,175 @@ +#!/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__ +<!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> +<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><br /> +</dt> +<dd> +The foo item. +</dd> +<p></p> +<dt><strong><a name="item_bar">bar</a></strong><br /> +</dt> +<dd> +The bar item. +</dd> +<p>This is a list within a list</p> +<ul> +<li></li> +The wiz item. +<p></p> +<li></li> +The waz item. +<p></p></ul> +<dt><strong><a name="item_baz">baz</a></strong><br /> +</dt> +<dd> +The baz item. +</dd> +<p></p></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><br /> +</li> +<li><strong><a name="item_sat_on_the">Sat <em>on</em> the</a></strong><br /> +</li> +<li><strong><a name="item_mat%3c%21%3e">Mat<!></a></strong><br /> +</li> +</ul> +<p>Title on the same line as the =item + numerical bullets</p> +<ol> +<li><strong><a name="item_cat">Cat</a></strong><br /> +</li> +<li><strong><a name="item_sat">Sat</a></strong><br /> +</li> +<li><strong><a name="item_mat">Mat</a></strong><br /> +</li> +</ol> +<p>No bullets, no title</p> +<dl> +<dt></dt> +<dd> +Cat +</dd> +<p></p> +<dt></dt> +<dd> +Sat +</dd> +<p></p> +<dt></dt> +<dd> +Mat +</dd> +<p></p></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@bar.com">mailto:foo@bar.com</a></p> +<p> +</p> +<hr /> +<h1><a name="see_also">SEE ALSO</a></h1> +<p>See also <a href="/pod2html/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> diff --git a/lib/Pod/t/pod2html-lib.pl b/lib/Pod/t/pod2html-lib.pl new file mode 100644 index 0000000000..b44a3aac0a --- /dev/null +++ b/lib/Pod/t/pod2html-lib.pl @@ -0,0 +1,37 @@ +require Cwd; +require Pod::Html; +require Config; +use File::Spec::Functions; + +sub convert_n_test { + my($podfile, $testname) = @_; + + my $cwd = Cwd::cwd(); + my $new_dir = catdir $cwd, "..", "lib", "Pod", "t"; + my $infile = catfile $new_dir, "$podfile.pod"; + my $outfile = catfile $new_dir, "$podfile.html"; + + Pod::Html::pod2html( + "--podpath=pod2html", + "--podroot=$cwd", + "--htmlroot=/", + "--infile=$infile", + "--outfile=$outfile" + ); + + + local $/; + # expected + my $expect = <DATA>; + $expect =~ s/\[PERLADMIN\]/$Config::Config{perladmin}/; + + # result + open my $in, $outfile or die "cannot open $outfile: $!"; + my $result = <$in>; + close $in; + + is($expect, $result, $testname); + +} + +1; |