line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Pod::Snippets; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
52157
|
use warnings; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
103
|
|
4
|
3
|
|
|
3
|
|
13
|
use strict; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
79
|
|
5
|
3
|
|
|
3
|
|
12
|
use Carp; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
230
|
|
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
2189
|
use Object::InsideOut; |
|
3
|
|
|
|
|
137646
|
|
|
3
|
|
|
|
|
14
|
|
8
|
3
|
|
|
3
|
|
1998
|
use Test::Pod::Snippets::Parser; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
525
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.03_03'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my @parser_of :Field; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my @do_verbatim :Field :Default(1) :Arg(extract_verbatim_bits); |
15
|
|
|
|
|
|
|
my @do_methods :Field :Default(0) :Arg(extract_methods); |
16
|
|
|
|
|
|
|
my @do_functions :Field :Default(0) :Arg(extract_functions); |
17
|
|
|
|
|
|
|
my @object_name :Field :Default('$thingy') :Arg(object_name); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub _init :Init { |
20
|
1
|
|
|
|
|
817
|
my $self = shift; |
21
|
|
|
|
|
|
|
|
22
|
1
|
|
|
|
|
31
|
$parser_of[ $$self ] = Test::Pod::Snippets::Parser->new; |
23
|
1
|
|
|
|
|
7
|
$parser_of[ $$self ]->{tps} = $self; |
24
|
3
|
|
|
3
|
|
18
|
} |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
19
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub get_object_name { |
27
|
2
|
|
|
2
|
0
|
3
|
my $self = shift; |
28
|
2
|
|
|
|
|
8
|
return $object_name[ $$self ]; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
32
|
|
|
|
|
|
|
|
33
|
7
|
|
|
7
|
0
|
30
|
sub is_extracting_verbatim_bits { return $do_verbatim[ ${$_[0]} ] } |
|
7
|
|
|
|
|
203
|
|
34
|
17
|
|
|
17
|
0
|
18
|
sub is_extracting_methods { return $do_methods[ ${$_[0]} ] } |
|
17
|
|
|
|
|
378
|
|
35
|
24
|
|
|
24
|
0
|
38
|
sub is_extracting_functions { return $do_functions[ ${$_[0]} ] } |
|
24
|
|
|
|
|
122
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub extract_verbatim_bits { |
40
|
1
|
|
|
1
|
1
|
1684
|
my $self = shift; |
41
|
1
|
|
|
|
|
4
|
return $do_verbatim[ $$self ] = shift; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub extract_methods { |
47
|
2
|
|
|
2
|
1
|
1589
|
my $self = shift; |
48
|
2
|
|
|
|
|
4
|
return $do_methods[ $$self ] = shift; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub extract_functions { |
54
|
1
|
|
|
1
|
1
|
5
|
my $self = shift; |
55
|
1
|
|
|
|
|
3
|
return $do_functions[ $$self ] = shift; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub generate_snippets { |
61
|
0
|
|
|
0
|
1
|
0
|
my( $self, @files ) = @_; |
62
|
0
|
|
|
|
|
0
|
my $i = 1; |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
0
|
print "generating snippets\n"; |
65
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
0
|
for ( @files ) { |
67
|
0
|
|
|
|
|
0
|
my $testfile = sprintf "t/pod-snippets-%02d.t", $i++; |
68
|
0
|
|
|
|
|
0
|
print "\t$_ => $testfile\n"; |
69
|
|
|
|
|
|
|
|
70
|
0
|
0
|
|
|
|
0
|
open my $fh, '>', $testfile |
71
|
|
|
|
|
|
|
or die "can't open $testfile for writing: $!\n"; |
72
|
0
|
|
|
|
|
0
|
print {$fh} $self->extract_snippets( $_ ); |
|
0
|
|
|
|
|
0
|
|
73
|
0
|
|
|
|
|
0
|
close $fh; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub extract_from_string { |
80
|
3
|
|
|
3
|
0
|
9
|
my ( $self, $string ) = @_; |
81
|
3
|
|
|
1
|
|
68
|
open my $pod_fh, '<', \$string; |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
82
|
3
|
|
|
|
|
1123
|
return $self->extract_snippets( $pod_fh ); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub extract_snippets { |
88
|
3
|
|
|
3
|
1
|
5
|
my( $self, $file ) = @_; |
89
|
|
|
|
|
|
|
|
90
|
3
|
|
|
|
|
6
|
my $filename_call = 'GLOB' ne ref $file; |
91
|
|
|
|
|
|
|
|
92
|
3
|
50
|
33
|
|
|
13
|
if( $filename_call and not -f $file ) { |
93
|
0
|
|
|
|
|
0
|
croak "$file doesn't seem to exist"; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
3
|
|
|
|
|
2
|
my $output; |
97
|
3
|
|
|
|
|
25
|
open my $fh, '>', \$output; |
98
|
|
|
|
|
|
|
|
99
|
3
|
50
|
|
|
|
8
|
if ( $filename_call ) { |
100
|
0
|
|
|
|
|
0
|
$parser_of[ $$self ]->parse_from_file( $file, $fh ); |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
else { |
103
|
3
|
|
|
|
|
376
|
$parser_of[ $$self ]->parse_from_filehandle( $file, $fh ); |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
3
|
50
|
|
|
|
9
|
my $filename = $filename_call ? $file : 'unknown'; |
107
|
|
|
|
|
|
|
|
108
|
3
|
|
|
|
|
15
|
return <<"END_TESTS"; |
109
|
|
|
|
|
|
|
use Test::More qw/ no_plan /; |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
no warnings; |
112
|
|
|
|
|
|
|
no strict; # things are likely to be sloppy |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
ok 1 => 'the tests compile'; |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
$output |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
ok 1 => 'we reached the end!'; |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
END_TESTS |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
sub snippets_ok { |
125
|
0
|
|
|
0
|
0
|
0
|
my( $self, $file ) = @_; |
126
|
|
|
|
|
|
|
|
127
|
0
|
|
|
|
|
0
|
my $code = $self->extract_snippets( $file ); |
128
|
|
|
|
|
|
|
|
129
|
0
|
|
|
|
|
0
|
eval $code; |
130
|
|
|
|
|
|
|
|
131
|
0
|
0
|
|
|
|
0
|
warn $@ if $@; |
132
|
|
|
|
|
|
|
|
133
|
0
|
|
|
|
|
0
|
return not $@; |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
1; # End of Test::Pod::Snippets |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
__END__ |