-
Notifications
You must be signed in to change notification settings - Fork 2
/
sections.t
120 lines (87 loc) · 3.75 KB
/
sections.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#! perl
use strict;
use warnings;
use Test::More;
use Test::LongString;
use lib 't/lib';
use TestDOM 'Pod::PseudoPod::DOM::Role::HTML';
use Pod::PseudoPod::DOM::App;
use File::Spec::Functions;
use File::Slurp;
use_ok( 'Pod::PseudoPod::DOM' ) or exit;
my %anchors;
my $file = read_file( catfile( qw( t test_file.pod ) ) );
my $result = parse_with_anchors( $file );
my $link = encode_link( 'SomeDocument' );
like_string $result,
qr!<h1 id="somedocument"><a name="$link"></a>Some Document</h1>!,
'0 heads should become chapter titles';
$link = encode_link( 'AHeading' );
like_string $result, qr!<h2 id="aheading"><a name="$link"></a>A Heading</h2>!,
'A heads should become section titles';
$link = encode_link( 'Bheading' );
like_string $result, qr!<h3 id="bheading"><a name="$link"></a>B heading</h3>!,
'B heads should become subsection titles';
$link = encode_link( 'cheading' );
like_string $result, qr!<h4 id="cheading"><a name="$link"></a>c heading</h4>!,
'C heads should become subsubsection titles';
like_string $result, qr!<h1 id="another.+">Another Suppressed Heading</h1>!,
'... chapter title TOC suppression should create heading';
$link = encode_link( 'AnotherSuppressedHeading' );
unlike_string $result, qr/<a name="$link">/,
'... without anchor';
like_string $result, qr!<h2 id="asuppressed.+">A Suppressed Heading</h2>!,
'... section title suppression should create heading';
$link = encode_link( 'ASuppressedHeading' );
unlike_string $result, qr/<a name="$link">/,
'... without anchor';
like_string $result, qr!<h3 id="yet.+ing">Yet Another Suppressed Heading</h3>!,
'... subsection title suppression should create heading';
$link = encode_link( 'YetAnotherSuppressedHeading' );
unlike_string $result, qr/<a name="$link">/,
'... without anchor';
like_string $result,
qr/<pre><code>\s*"This text.+--.+ \$text."\n/s,
'programlistings should become unescaped, verbatim result';
like_string $result,
qr!<pre><code>\s*This should also be \$unm0d\+ified</code>!s,
'screens should become unescaped, verbatim result';
like_string $result,
qr/class="blockquote">\s*<p>Blockquoted text.+"escaped"\./,
'blockquoted text gets escaped';
like_string $result, qr!<ul>\s*<li>Verbatim</li>!s,
'text-item lists need description formatting to start';
like_string $result, qr!<li>items</li>\s*</ul>!,
'... and to end';
like_string $result, qr!rule too:</p>\s*<ul>!s,
'bulleted lists need to start as unordered lists';
like_string $result, qr!<ul>\s*<li>BANG</li>!s,
'bulleted lists need itemized formatting to start';
like_string $result, qr|<li>BANGERANG!</li>\s*</ul>|,
'... and to end';
like_string $result,
qr!<ul>\s*<li><p>wakawaka</p>\s*<p>What Pac-Man says.</p>\s*</li>!s,
'definition lists need description formatting to start';
like_string $result,
qr!<li><p>ook ook</p>\s*<p>What.+says\.</p>\s*</li>\s*</ul>!,
'... and to end';
like_string $result,
qr!<div class="literal"><p>Here are several paragraphs.</p>!s,
'literal sections should work';
like_string $result,
qr!<p>They should have <em>newlines</em> in between them\.</p>!s,
'... even with subelements of paragraphs';
like_string $result, qr!them\.</p>\s*<p></p>!,
'... even with extra embedded newlines';
like_string $result,
qr!part of some document \(.+?>Some Document</a>; .+?>Some Document</a>\)!,
'Z<> and A<> tags should use contents of previous heading for text';
TODO:
{
local $TODO = "Seems like an upstream bug here\n";
like_string $result, qr/\\begin{enumerate}.+\\item \[2\] First/,
'enumerated lists need their numbers intact';
like_string $result, qr/\\item \[77\].+Fooled you!.+\\end{itemize}/s,
'... and their itemized endings okay';
}
done_testing;