From: Stas Bekman Date: Tue, 19 Mar 2002 14:39:03 +0000 (+0800) Subject: [tests for Pod::Html] X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=78343be7b86f9004a04a6659b6df1011666cda9e;p=p5sagit%2Fp5-mst-13.2.git [tests for Pod::Html] Message-ID: p4raw-id: //depot/perl@15383 --- diff --git a/MANIFEST b/MANIFEST index 04a4628..ef1cc6e 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1287,6 +1287,11 @@ lib/Pod/t/basic.ovr podlators test lib/Pod/t/basic.pod podlators test lib/Pod/t/basic.t podlators test lib/Pod/t/basic.txt podlators test +lib/Pod/t/htmlescp.t pod2html escape test +lib/Pod/t/htmlescp.pod pod2html escape test input data +lib/Pod/t/htmlview.t pod2html render test +lib/Pod/t/htmlview.pod pod2html render test input data +lib/Pod/t/pod2html-lib.pl pod2html testing library lib/Pod/t/Functions.t See if Pod::Functions works lib/Pod/t/InputObjects.t See if Pod::InputObjects works lib/Pod/t/latex.t See if Pod::LaTeX works diff --git a/lib/Pod/t/htmlescp.pod b/lib/Pod/t/htmlescp.pod new file mode 100644 index 0000000..dc53ca7 --- /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 and E. + +Here is some B text, some I plus F +file and something that looks like an EhtmlE 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 0000000..b7913c5 --- /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__ + + + +NAME + + + + + +

+ + + + + +
+

+

+

NAME

+

Escape Sequences Test

+

+

+
+

DESCRIPTION

+

I am a stupid fool who puts naked < & > characters in my POD +instead of escaping them as < and >.

+

Here is some bold text, some italic plus /etc/fstab +file and something that looks like an <html> tag. +This is some $code($arg1).

+ + + + diff --git a/lib/Pod/t/htmlview.pod b/lib/Pod/t/htmlview.pod new file mode 100644 index 0000000..62ac71c --- /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 text, some I and something that looks +like an EhtmlE tag. This is some C<$code($arg1)>. + +This C and I tags>. These can +be nested, allowing B italic> text>. The module also +supports the extended B<< syntax >> and permits I<< nested tags E +other B<<< cool >>> stuff >> + +=head1 METHODS =E 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 Cat + +=item * Sat S the> + +=item * MatE!E + +=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
+

+blah blah +

+ +intermediate text + +=begin html + + +HTML + + +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, the L and L +manpages and the other interesting file F +as well. + +=cut diff --git a/lib/Pod/t/htmlview.t b/lib/Pod/t/htmlview.t new file mode 100644 index 0000000..8963463 --- /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__ + + + +NAME + + + + + +

+ + + + + +
+

+

+

NAME

+

Test HTML Rendering

+

+

+
+

SYNOPSIS

+
+    use My::Module;
+
+    my $module = My::Module->new();
+

+

+
+

DESCRIPTION

+

This is the description.

+
+    Here is a verbatim section.
+

This is some more regular text.

+

Here is some bold text, some italic and something that looks +like an <html> tag. This is some $code($arg1).

+

This text contains embedded bold and italic tags. These can +be nested, allowing bold and bold & italic text. The module also +supports the extended syntax > and permits nested tags & +other cool > stuff >>

+

+

+
+

METHODS => OTHER STUFF

+

Here is a list of methods

+

+

+

new()

+

Constructor method. Accepts the following config options:

+
+
foo
+
+
+The foo item. +
+

+
bar
+
+
+The bar item. +
+

This is a list within a list

+
    +
  • +The wiz item. +

    +
  • +The waz item. +

+
baz
+
+
+The baz item. +
+

+

Title on the same line as the =item + * bullets

+ +

Title on the same line as the =item + numerical bullets

+
    +
  1. Cat
    +
  2. +
  3. Sat
    +
  4. +
  5. Mat
    +
  6. +
+

No bullets, no title

+
+
+
+Cat +
+

+
+
+Sat +
+

+
+
+Mat +
+

+

+

+

old()

+

Destructor method

+

+

+
+

TESTING FOR AND BEGIN

+
+

+blah blah +

intermediate text

+ +HTML +some text

+

+
+

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

+

+

+
+

SEE ALSO

+

See also Test Page 2, the the Your::Module manpage and the Their::Module manpage +manpages and the other interesting file /usr/local/my/module/rocks +as well.

+ + + + diff --git a/lib/Pod/t/pod2html-lib.pl b/lib/Pod/t/pod2html-lib.pl new file mode 100644 index 0000000..b44a3aa --- /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 = ; + $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;