line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Pod::Content; |
2
|
2
|
|
|
2
|
|
26165
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
84
|
|
3
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
66
|
|
4
|
2
|
|
|
2
|
|
10
|
use base qw(Pod::Simple Test::More); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
2790
|
|
5
|
2
|
|
|
2
|
|
124548
|
use Exporter; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
1724
|
|
6
|
2
|
|
|
2
|
|
2123
|
use version; our $VERSION = qv('0.0.6'); |
|
2
|
|
|
|
|
9557
|
|
|
2
|
|
|
|
|
16
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our @EXPORT = qw(pod_section_is pod_section_like); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# Globals for running a simple state machine |
11
|
|
|
|
|
|
|
my $_state = q{}; |
12
|
|
|
|
|
|
|
my $_section = q{}; |
13
|
|
|
|
|
|
|
my $_content = q{}; |
14
|
|
|
|
|
|
|
my $_test_content_sub; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# cleanup everything once we've run our test |
17
|
|
|
|
|
|
|
sub _reset { |
18
|
4
|
|
|
4
|
|
47
|
my $parser = shift; |
19
|
4
|
|
|
|
|
12
|
$_state = q{}; |
20
|
4
|
|
|
|
|
7
|
$_section = q{}; |
21
|
4
|
|
|
|
|
8
|
$_content = q{}; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# source_dead is not reliable - just die to force terminating the |
24
|
|
|
|
|
|
|
# parser run |
25
|
4
|
|
|
|
|
29
|
$parser->source_dead(1); |
26
|
4
|
|
|
|
|
220
|
die "OK\n"; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub pod_section_is { |
30
|
1
|
|
|
1
|
1
|
11
|
my ($name, $section, $content, $comment ) = @_; |
31
|
|
|
|
|
|
|
|
32
|
1
|
|
|
|
|
2
|
my $found = 0; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
$_test_content_sub = sub { |
35
|
2
|
|
|
2
|
|
5
|
my ($parser, $section_name, $test_content) = @_; |
36
|
2
|
100
|
|
|
|
7
|
if ($section_name eq $section) { |
37
|
1
|
|
|
|
|
3
|
$found++; |
38
|
1
|
|
|
|
|
7
|
Test::More::is($test_content, $content, $comment); |
39
|
1
|
|
|
|
|
736
|
_reset($parser); |
40
|
|
|
|
|
|
|
} |
41
|
1
|
|
|
|
|
8
|
}; |
42
|
|
|
|
|
|
|
|
43
|
1
|
|
|
|
|
3
|
eval { Test::Pod::Content->filter( _find_file($name) ) }; |
|
1
|
|
|
|
|
5
|
|
44
|
1
|
50
|
|
|
|
5
|
if ($@) { die $@ if ($@ !~m{^OK\n$}xm) }; |
|
1
|
50
|
|
|
|
6
|
|
45
|
|
|
|
|
|
|
|
46
|
1
|
50
|
|
|
|
4
|
if (not $found) { |
47
|
0
|
|
|
|
|
0
|
Test::More::fail $comment; |
48
|
|
|
|
|
|
|
} |
49
|
1
|
|
|
|
|
3
|
return; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub pod_section_like { |
53
|
3
|
|
|
3
|
1
|
223
|
my ($name, $section, $regex, $comment ) = @_; |
54
|
|
|
|
|
|
|
|
55
|
3
|
|
|
|
|
5
|
my $found = 0; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
$_test_content_sub = sub { |
58
|
19
|
|
|
19
|
|
34
|
my ($parser, $section_name, $test_content) = @_; |
59
|
19
|
100
|
|
|
|
59
|
if ($section_name eq $section) { |
60
|
3
|
|
|
|
|
5
|
$found++; |
61
|
3
|
|
|
|
|
18
|
Test::More::like($test_content, $regex, $comment); |
62
|
3
|
|
|
|
|
1524
|
_reset($parser); |
63
|
|
|
|
|
|
|
} |
64
|
3
|
|
|
|
|
20
|
}; |
65
|
|
|
|
|
|
|
|
66
|
3
|
|
|
|
|
16
|
eval { Test::Pod::Content->filter( _find_file($name) ) }; |
|
3
|
|
|
|
|
10
|
|
67
|
3
|
50
|
|
|
|
14
|
if ($@) { die $@ if ($@ !~m{^OK\n$}xm) }; |
|
3
|
50
|
|
|
|
20
|
|
68
|
|
|
|
|
|
|
|
69
|
3
|
50
|
|
|
|
11
|
if (not $found) { |
70
|
0
|
|
|
|
|
0
|
Test::More::fail $comment; |
71
|
|
|
|
|
|
|
} |
72
|
3
|
|
|
|
|
111
|
return; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub _find_file { |
76
|
4
|
|
|
4
|
|
8
|
my $name = shift; |
77
|
4
|
50
|
|
|
|
53
|
return $name if (-e $name); |
78
|
4
|
|
|
|
|
13
|
for my $path (@INC) { |
79
|
27
|
100
|
|
|
|
643
|
return "$path/$name" if -e "$path/$name"; |
80
|
|
|
|
|
|
|
} |
81
|
2
|
|
|
|
|
13
|
$name =~s{::}{/}xmg; |
82
|
2
|
|
|
|
|
4
|
$name .= '.pm'; |
83
|
2
|
|
|
|
|
6
|
for my $path (@INC) { |
84
|
5
|
100
|
|
|
|
138
|
return "$path/$name" if -e "$path/$name"; |
85
|
|
|
|
|
|
|
} |
86
|
0
|
|
|
|
|
0
|
return; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub _handle_element_start { |
90
|
76
|
|
|
76
|
|
28466
|
my($parser, $element_name, $attr_hash_r) = @_; |
91
|
|
|
|
|
|
|
# print "START $element_name\n"; |
92
|
76
|
100
|
|
|
|
206
|
if ($element_name =~m{^head\d$}xm) { |
93
|
|
|
|
|
|
|
# Test last section's content on every new section |
94
|
21
|
|
|
|
|
49
|
$_test_content_sub->($parser, $_section, $_content); |
95
|
17
|
|
|
|
|
22
|
$_state = 'section'; |
96
|
17
|
|
|
|
|
28
|
$_content = q{}; |
97
|
|
|
|
|
|
|
} |
98
|
72
|
|
|
|
|
143
|
return; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub _handle_element_end { |
102
|
68
|
|
|
68
|
|
353
|
my($parser, $element_name) = @_; |
103
|
|
|
|
|
|
|
# print "END $element_name\n"; |
104
|
68
|
50
|
|
|
|
147
|
if ($element_name =~m{^Document$}xm) { |
105
|
0
|
|
|
|
|
0
|
$_test_content_sub->($parser, $_section, $_content); |
106
|
|
|
|
|
|
|
} |
107
|
68
|
|
|
|
|
113
|
return; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub _handle_text { |
111
|
68
|
|
|
68
|
|
486
|
my($parser, $text) = @_; |
112
|
|
|
|
|
|
|
# print "TEXT $text\n"; |
113
|
68
|
100
|
|
|
|
146
|
if ($_state eq 'section') { |
114
|
17
|
|
|
|
|
22
|
$_section = $text; |
115
|
17
|
|
|
|
|
26
|
$_state = 'section_content_start'; |
116
|
17
|
|
|
|
|
41
|
return; |
117
|
|
|
|
|
|
|
} |
118
|
51
|
50
|
|
|
|
100
|
if ($_state eq 'section_content_start') { |
119
|
51
|
|
|
|
|
95
|
$_content .= $text; |
120
|
|
|
|
|
|
|
} |
121
|
51
|
|
|
|
|
115
|
return; |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
1; |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
__END__ |