| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package Test::ClassAPI; |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
14
|
|
|
|
1
|
|
|
|
|
10
|
|
|
|
1
|
|
|
|
|
14
|
|
|
7
|
1
|
|
|
1
|
|
509
|
use strict; |
|
|
1
|
|
|
|
|
11
|
|
|
|
1
|
|
|
|
|
15
|
|
|
8
|
1
|
|
|
1
|
|
15
|
use UNIVERSAL 'isa'; |
|
|
1
|
|
|
|
|
9
|
|
|
|
1
|
|
|
|
|
10
|
|
|
9
|
1
|
|
|
1
|
|
52
|
use Test::More (); |
|
|
1
|
|
|
|
|
10
|
|
|
|
1
|
|
|
|
|
10
|
|
|
10
|
1
|
|
|
1
|
|
27
|
use Config::Tiny (); |
|
|
1
|
|
|
|
|
32
|
|
|
|
1
|
|
|
|
|
12
|
|
|
11
|
|
|
|
|
|
|
use Class::Inspector (); |
|
12
|
1
|
|
|
1
|
|
20
|
|
|
|
1
|
|
|
|
|
10
|
|
|
|
1
|
|
|
|
|
17
|
|
|
13
|
|
|
|
|
|
|
use vars qw{$VERSION $CONFIG $SCHEDULE $EXECUTED %IGNORE *DATA}; |
|
14
|
1
|
|
|
1
|
|
15
|
BEGIN { |
|
15
|
|
|
|
|
|
|
$VERSION = '1.02'; |
|
16
|
|
|
|
|
|
|
|
|
17
|
1
|
|
|
|
|
10
|
|
|
18
|
1
|
|
|
|
|
9
|
$CONFIG = undef; |
|
19
|
|
|
|
|
|
|
$SCHEDULE = undef; |
|
20
|
|
|
|
|
|
|
|
|
21
|
1
|
|
|
|
|
9
|
|
|
22
|
|
|
|
|
|
|
$EXECUTED = ''; |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
|
25
|
1
|
|
|
|
|
9
|
|
|
|
2
|
|
|
|
|
27
|
|
|
26
|
|
|
|
|
|
|
%IGNORE = map { $_, 1 } qw{isa can}; |
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
|
32
|
4
|
|
|
4
|
|
36
|
sub _super_path($) { |
|
33
|
4
|
|
|
|
|
36
|
my $class = shift; |
|
34
|
4
|
|
|
|
|
38
|
my @path = (); |
|
35
|
4
|
|
|
|
|
43
|
my @queue = ( $class ); |
|
36
|
4
|
|
|
|
|
47
|
my %seen = ( $class => 1 ); |
|
37
|
1
|
|
|
1
|
|
18
|
while ( my $cl = shift @queue ) { |
|
|
1
|
|
|
|
|
68
|
|
|
|
1
|
|
|
|
|
17
|
|
|
38
|
7
|
|
|
|
|
68
|
no strict 'refs'; |
|
39
|
3
|
|
|
|
|
44
|
push @path, $cl; |
|
|
3
|
|
|
|
|
28
|
|
|
40
|
3
|
|
|
|
|
27
|
unshift @queue, grep { ! $seen{$_}++ } |
|
|
3
|
|
|
|
|
32
|
|
|
|
7
|
|
|
|
|
107
|
|
|
41
|
7
|
|
|
|
|
58
|
map { s/^::/main::/; s/\'/::/g; $_ } |
|
42
|
|
|
|
|
|
|
( @{"${cl}::ISA"} ); |
|
43
|
|
|
|
|
|
|
} |
|
44
|
4
|
|
|
|
|
47
|
|
|
45
|
|
|
|
|
|
|
@path; |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
|
56
|
1
|
|
|
1
|
0
|
11
|
sub init { |
|
57
|
|
|
|
|
|
|
my $class = shift; |
|
58
|
|
|
|
|
|
|
|
|
59
|
1
|
50
|
|
|
|
32
|
|
|
60
|
|
|
|
|
|
|
*DATA = isa( $_[0], 'GLOB' ) ? shift : *main::DATA; |
|
61
|
|
|
|
|
|
|
|
|
62
|
1
|
|
|
|
|
13
|
|
|
63
|
1
|
50
|
|
|
|
68
|
local $/ = undef; |
|
64
|
|
|
|
|
|
|
$CONFIG = Config::Tiny->read_string( <DATA> ) |
|
65
|
|
|
|
|
|
|
or die 'Failed to load test configuration: ' |
|
66
|
1
|
50
|
|
|
|
810
|
. Config::Tiny->errstr; |
|
67
|
|
|
|
|
|
|
$SCHEDULE = delete $CONFIG->{_} |
|
68
|
|
|
|
|
|
|
or die 'Config does not have a schedule defined'; |
|
69
|
|
|
|
|
|
|
|
|
70
|
1
|
|
|
|
|
13
|
|
|
71
|
6
|
|
50
|
|
|
61
|
foreach my $tclass ( keys %$CONFIG ) { |
|
72
|
6
|
|
|
|
|
50
|
$SCHEDULE->{$tclass} ||= 'class'; |
|
|
6
|
|
|
|
|
67
|
|
|
73
|
19
|
50
|
|
|
|
215
|
foreach my $test ( keys %{$CONFIG->{$tclass}} ) { |
|
74
|
0
|
|
0
|
|
|
0
|
next unless $CONFIG->{$tclass}->{$test} eq 'implements'; |
|
75
|
|
|
|
|
|
|
$SCHEDULE->{$test} ||= 'interface'; |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
|
80
|
1
|
|
|
|
|
14
|
|
|
81
|
6
|
|
|
|
|
56
|
foreach my $tclass ( keys %$SCHEDULE ) { |
|
82
|
6
|
50
|
|
|
|
65
|
my $value = $SCHEDULE->{$tclass}; |
|
83
|
0
|
|
|
|
|
0
|
unless ( $value =~ /^(?:class|abstract|interface)$/ ) { |
|
84
|
|
|
|
|
|
|
die "Invalid schedule option '$value' for class '$tclass'"; |
|
85
|
6
|
50
|
|
|
|
64
|
} |
|
86
|
0
|
|
|
|
|
0
|
unless ( $CONFIG->{$tclass} ) { |
|
87
|
|
|
|
|
|
|
die "No section '[$tclass]' defined for schedule class"; |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
} |
|
90
|
1
|
|
|
|
|
13
|
|
|
91
|
|
|
|
|
|
|
1; |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
|
95
|
1
|
|
|
1
|
1
|
12
|
sub execute { |
|
96
|
1
|
50
|
|
|
|
12
|
my $class = shift; |
|
97
|
0
|
|
|
|
|
0
|
if ( $EXECUTED ) { |
|
98
|
|
|
|
|
|
|
die 'You can only execute once, use another test script'; |
|
99
|
1
|
50
|
|
|
|
16
|
} |
|
100
|
|
|
|
|
|
|
$class->init unless $CONFIG; |
|
101
|
|
|
|
|
|
|
|
|
102
|
1
|
|
|
|
|
10
|
|
|
|
1
|
|
|
|
|
13
|
|
|
103
|
1
|
|
|
|
|
11
|
my @options = map { lc $_ } @_; |
|
|
1
|
|
|
|
|
12
|
|
|
104
|
1
|
|
|
|
|
10
|
my $CHECK_UNKNOWN_METHODS = !! grep { $_ eq 'complete' } @options; |
|
|
1
|
|
|
|
|
12
|
|
|
105
|
|
|
|
|
|
|
my $CHECK_FUNCTION_COLLISIONS = !! grep { $_ eq 'collisions' } @options; |
|
106
|
|
|
|
|
|
|
|
|
107
|
1
|
50
|
|
|
|
22
|
|
|
108
|
0
|
|
|
|
|
0
|
unless ( Test::More->builder->has_plan ) { |
|
109
|
|
|
|
|
|
|
Test::More::plan( 'no_plan' ); |
|
110
|
|
|
|
|
|
|
} |
|
111
|
|
|
|
|
|
|
|
|
112
|
1
|
|
|
|
|
20
|
|
|
113
|
1
|
|
|
|
|
11
|
my @classes = sort keys %$SCHEDULE; |
|
|
6
|
|
|
|
|
67
|
|
|
114
|
|
|
|
|
|
|
@classes = grep { $SCHEDULE->{$_} ne 'interface' } @classes; |
|
115
|
|
|
|
|
|
|
|
|
116
|
1
|
|
|
|
|
11
|
|
|
117
|
6
|
|
|
|
|
734
|
foreach my $class ( @classes ) { |
|
118
|
|
|
|
|
|
|
Test::More::ok( Class::Inspector->loaded( $class ), "Class '$class' is loaded" ); |
|
119
|
|
|
|
|
|
|
} |
|
120
|
|
|
|
|
|
|
|
|
121
|
1
|
|
|
|
|
11
|
|
|
|
6
|
|
|
|
|
135
|
|
|
122
|
1
|
|
|
|
|
13
|
@classes = grep { $SCHEDULE->{$_} eq 'class' } @classes; |
|
123
|
|
|
|
|
|
|
foreach my $class ( @classes ) { |
|
124
|
4
|
|
|
|
|
46
|
|
|
|
7
|
|
|
|
|
78
|
|
|
125
|
|
|
|
|
|
|
my @path = grep { $SCHEDULE->{$_} } _super_path($class); |
|
126
|
|
|
|
|
|
|
|
|
127
|
4
|
|
|
|
|
39
|
|
|
128
|
4
|
|
|
|
|
35
|
my %known_methods = (); |
|
129
|
4
|
|
|
|
|
34
|
my @implements = (); |
|
130
|
7
|
|
|
|
|
60
|
foreach my $parent ( @path ) { |
|
|
7
|
|
|
|
|
102
|
|
|
131
|
29
|
|
|
|
|
346
|
foreach my $test ( keys %{$CONFIG->{$parent}} ) { |
|
132
|
29
|
100
|
|
|
|
277
|
my $type = $CONFIG->{$parent}->{$test}; |
|
|
|
50
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
if ( $type eq 'method' ) { |
|
134
|
26
|
|
|
|
|
235
|
|
|
135
|
26
|
|
|
|
|
267
|
$known_methods{$test}++; |
|
136
|
|
|
|
|
|
|
Test::More::can_ok( $class, $test ); |
|
137
|
|
|
|
|
|
|
} elsif ( $type eq 'isa' ) { |
|
138
|
3
|
|
|
|
|
72
|
|
|
139
|
|
|
|
|
|
|
Test::More::ok( isa( $class, $test ), "$class isa $test" ); |
|
140
|
29
|
50
|
|
|
|
1027
|
} |
|
141
|
|
|
|
|
|
|
next unless $type eq 'implements'; |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
|
|
149
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
150
|
0
|
0
|
|
|
|
0
|
next if grep { $_ eq $test } @path; |
|
|
0
|
|
|
|
|
0
|
|
|
151
|
0
|
|
|
|
|
0
|
next if grep { $_ eq $test } @implements; |
|
152
|
|
|
|
|
|
|
push @implements, $test; |
|
153
|
|
|
|
|
|
|
} |
|
154
|
|
|
|
|
|
|
} |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
|
|
157
|
4
|
|
|
|
|
43
|
|
|
158
|
0
|
|
|
|
|
0
|
foreach my $parent ( @implements ) { |
|
|
0
|
|
|
|
|
0
|
|
|
159
|
0
|
|
|
|
|
0
|
foreach my $test ( keys %{$CONFIG->{$parent}} ) { |
|
160
|
0
|
0
|
|
|
|
0
|
my $type = $CONFIG->{$parent}->{$test}; |
|
161
|
|
|
|
|
|
|
if ( $type eq 'method' ) { |
|
162
|
0
|
|
|
|
|
0
|
|
|
163
|
0
|
|
|
|
|
0
|
$known_methods{$test}++; |
|
164
|
|
|
|
|
|
|
Test::More::can_ok( $class, $test ); |
|
165
|
|
|
|
|
|
|
} |
|
166
|
|
|
|
|
|
|
} |
|
167
|
|
|
|
|
|
|
} |
|
168
|
4
|
50
|
|
|
|
43
|
|
|
169
|
|
|
|
|
|
|
if ( $CHECK_UNKNOWN_METHODS ) { |
|
170
|
4
|
50
|
|
|
|
58
|
|
|
171
|
|
|
|
|
|
|
my $methods = Class::Inspector->methods( $class, 'public', 'expanded' ) |
|
172
|
0
|
|
|
|
|
0
|
or die "Failed to find public methods for class '$class'"; |
|
|
0
|
|
|
|
|
0
|
|
|
173
|
26
|
|
33
|
|
|
301
|
@$methods = grep { $_->[2] !~ /^[A-Z_]+$/ } |
|
174
|
4
|
|
|
|
|
40
|
grep { $_->[1] ne 'Exporter' } |
|
175
|
4
|
50
|
|
|
|
45
|
grep { ! ($known_methods{$_->[2]} or $IGNORE{$_->[2]}) } @$methods; |
|
176
|
0
|
|
|
|
|
0
|
if ( @$methods ) { |
|
|
0
|
|
|
|
|
0
|
|
|
177
|
|
|
|
|
|
|
print STDERR join '', map { "# Found undocumented method '$_->[2]' defined at '$_->[0]'\n" } @$methods; |
|
178
|
4
|
|
|
|
|
54
|
} |
|
179
|
|
|
|
|
|
|
Test::More::is( scalar(@$methods), 0, "No unknown public methods in '$class'" ); |
|
180
|
|
|
|
|
|
|
} |
|
181
|
4
|
50
|
|
|
|
90
|
|
|
182
|
|
|
|
|
|
|
if ( $CHECK_FUNCTION_COLLISIONS ) { |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
|
|
191
|
1
|
|
|
1
|
|
22
|
|
|
|
1
|
|
|
|
|
10
|
|
|
|
1
|
|
|
|
|
49
|
|
|
192
|
0
|
|
|
|
|
0
|
no strict 'refs'; |
|
193
|
0
|
|
|
|
|
0
|
my @collisions = (); |
|
|
0
|
|
|
|
|
0
|
|
|
194
|
0
|
0
|
|
|
|
0
|
foreach my $symbol ( sort keys %{"${class}::"} ) { |
|
195
|
0
|
0
|
|
|
|
0
|
next unless $symbol =~ s/::$//; |
|
|
0
|
|
|
|
|
0
|
|
|
196
|
0
|
|
|
|
|
0
|
next unless defined *{"${class}::${symbol}"}{CODE}; |
|
197
|
0
|
|
|
|
|
0
|
print STDERR "Found function collision: ${class}->${symbol} clashes with ${class}::${symbol}\n"; |
|
198
|
|
|
|
|
|
|
push @collisions, $symbol; |
|
199
|
0
|
|
|
|
|
0
|
} |
|
200
|
|
|
|
|
|
|
Test::More::is( scalar(@collisions), 0, "No function/class collisions in '$class'" ); |
|
201
|
|
|
|
|
|
|
} |
|
202
|
|
|
|
|
|
|
} |
|
203
|
1
|
|
|
|
|
14
|
|
|
204
|
|
|
|
|
|
|
1; |
|
205
|
|
|
|
|
|
|
} |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
1; |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
__END__ |
|
210
|
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
#line 339 |
|
212
|
|
|
|
|
|
|
|