xref: /openbsd-src/gnu/usr.bin/perl/cpan/Pod-Simple/t/html01.t (revision f2da64fbbbf1b03f09f390ab01267c93dfd77c4c)
1# Testing HTML paragraphs
2
3BEGIN {
4    if($ENV{PERL_CORE}) {
5        chdir 't';
6        @INC = '../lib';
7    }
8}
9
10use strict;
11use Test;
12BEGIN { plan tests => 12 };
13
14#use Pod::Simple::Debug (10);
15
16use Pod::Simple::HTML;
17
18sub x ($;&) {
19  my $code = $_[1];
20  Pod::Simple::HTML->_out(
21  sub{  $_[0]->bare_output(1); $code->($_[0]) if $code  },
22  "=pod\n\n$_[0]",
23) }
24
25ok( x(
26q{
27=pod
28
29This is a paragraph
30
31=cut
32}),
33  qq{\n<p>This is a paragraph</p>\n},
34  "paragraph building"
35);
36
37
38ok( x(qq{=pod\n\nThis is a paragraph}),
39 qq{\n<p>This is a paragraph</p>\n},
40 "paragraph building"
41);
42
43
44ok( x(qq{This is a paragraph}),
45 qq{\n<p>This is a paragraph</p>\n},
46 "paragraph building"
47);
48
49
50
51ok(x(
52'=head1 This is a heading')
53 => q{/\s*<h1><a[^<>]+>This\s+is\s+a\s+heading</a></h1>\s*$/},
54  "heading building"
55);
56
57ok(x('=head1 This is a heading', sub { $_[0]->html_h_level(2) })
58 => q{/\s*<h2><a[^<>]+>This\s+is\s+a\s+heading</a></h2>\s*$/},
59  "heading building"
60);
61
62ok(x(
63'=head2 This is a heading too')
64 => q{/\s*<h2><a[^<>]+>This\s+is\s+a\s+heading\s+too</a></h2>\s*$/},
65  "heading building"
66);
67
68ok(x(
69'=head3 Also, this is a heading')
70 => q{/\s*<h3><a[^<>]+>Also,\s+this\s+is\s+a\s+heading</a></h3>\s*$/},
71  "heading building"
72);
73
74
75ok(x(
76'=head4 This, too, is a heading')
77 => q{/\s*<h4><a[^<>]+>This,\s+too,\s+is\s+a\s+heading</a></h4>\s*$/},
78  "heading building"
79);
80
81ok(x(
82'=head2 Yada Yada Operator
83X<...> X<... operator> X<yada yada operator>')
84 => q{/name="Yada_Yada_Operator"/},
85  "heading anchor name"
86);
87
88ok(
89    x("=over 4\n\n=item one\n\n=item two\n\nHello\n\n=back\n"),
90    q{
91<dl>
92<dt><a name="one"
93>one</a></dt>
94
95<dd>
96<dt><a name="two"
97>two</a></dt>
98
99<dd>
100<p>Hello</p>
101</dd>
102</dl>
103}
104);
105
106# Check subclass.
107SUBCLASS: {
108    package My::Pod::HTML;
109    use vars '@ISA', '$VERSION';
110    @ISA = ('Pod::Simple::HTML');
111    $VERSION = '0.01';
112    sub do_section { 'howdy' }
113}
114
115ok(
116    My::Pod::HTML->_out(
117        sub{  $_[0]->bare_output(1)  },
118        "=pod\n\n=over\n\n=item Foo\n\n=back\n",
119    ),
120    "\n<dl>\n<dt><a name=\"howdy\"\n>Foo</a></dt>\n</dl>\n",
121);
122
123print "# And one for the road...\n";
124ok 1;
125
126