line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Classy; |
2
|
|
|
|
|
|
|
|
3
|
8
|
|
|
8
|
|
13343
|
use strict; |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
292
|
|
4
|
8
|
|
|
8
|
|
39
|
use warnings; |
|
8
|
|
|
|
|
12
|
|
|
8
|
|
|
|
|
278
|
|
5
|
8
|
|
|
8
|
|
4504
|
use Test::More (); |
|
8
|
|
|
|
|
104693
|
|
|
8
|
|
|
|
|
201
|
|
6
|
8
|
|
|
8
|
|
2907
|
use Test::Classy::Util; |
|
8
|
|
|
|
|
13
|
|
|
8
|
|
|
|
|
209
|
|
7
|
8
|
|
|
8
|
|
4059
|
use Sub::Install qw( install_sub ); |
|
8
|
|
|
|
|
11519
|
|
|
8
|
|
|
|
|
39
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.10'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my @tests; |
12
|
|
|
|
|
|
|
my $caller = caller; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
install_sub({ |
15
|
|
|
|
|
|
|
as => 'load_tests_from', |
16
|
|
|
|
|
|
|
into => $caller, |
17
|
|
|
|
|
|
|
code => sub (@) { |
18
|
7
|
|
|
7
|
|
655
|
my @monikers = @_; |
19
|
|
|
|
|
|
|
|
20
|
7
|
|
|
|
|
3571
|
require Module::Find; |
21
|
|
|
|
|
|
|
|
22
|
7
|
|
|
|
|
7693
|
@tests = Test::Classy::_look_for_tests(@monikers); |
23
|
7
|
|
|
|
|
13
|
foreach my $moniker ( @monikers ) { |
24
|
7
|
|
|
|
|
27
|
push @tests, grep { $_->isa('Test::Classy::Base') } |
|
23
|
|
|
|
|
306
|
|
25
|
|
|
|
|
|
|
Module::Find::useall( $moniker ); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
}, |
28
|
|
|
|
|
|
|
}); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
install_sub({ |
31
|
|
|
|
|
|
|
as => 'load_test', |
32
|
|
|
|
|
|
|
into => $caller, |
33
|
|
|
|
|
|
|
code => sub ($) { |
34
|
1
|
|
|
1
|
|
2
|
my $moniker = shift; |
35
|
1
|
50
|
|
|
|
15
|
unless ($moniker->can('import')) { |
36
|
0
|
0
|
|
|
|
0
|
eval "require $moniker" or die $@; |
37
|
|
|
|
|
|
|
} |
38
|
1
|
|
|
|
|
5
|
push @tests, $moniker; |
39
|
|
|
|
|
|
|
}, |
40
|
|
|
|
|
|
|
}); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
install_sub({ |
43
|
|
|
|
|
|
|
as => 'limit_tests_by', |
44
|
|
|
|
|
|
|
into => $caller, |
45
|
|
|
|
|
|
|
code => sub (@) { |
46
|
1
|
|
|
1
|
|
5
|
my @monikers = @_; |
47
|
|
|
|
|
|
|
|
48
|
1
|
|
|
|
|
2
|
foreach my $class ( @tests ) { |
49
|
2
|
|
|
|
|
9
|
$class->_limit( @monikers ); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
}, |
52
|
|
|
|
|
|
|
}); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
install_sub({ |
55
|
|
|
|
|
|
|
as => 'run_tests', |
56
|
|
|
|
|
|
|
into => $caller, |
57
|
|
|
|
|
|
|
code => sub (;@) { |
58
|
6
|
|
|
6
|
|
29
|
my @args = @_; |
59
|
|
|
|
|
|
|
|
60
|
6
|
50
|
|
|
|
22
|
unless (@tests) { |
61
|
0
|
|
|
|
|
0
|
@tests = Test::Classy::_look_for_tests(); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
6
|
100
|
|
|
|
49
|
unless (Test::Classy::Util::_planned()) { |
65
|
5
|
|
|
|
|
119
|
Test::More::plan tests => __PACKAGE__->plan; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
6
|
|
|
|
|
2001
|
foreach my $class ( @tests ) { |
69
|
18
|
|
|
|
|
152
|
$class->_run_tests( @args ); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
}, |
72
|
|
|
|
|
|
|
}); |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub _look_for_tests { |
75
|
7
|
|
|
7
|
|
509
|
my @queue = @_; |
76
|
|
|
|
|
|
|
|
77
|
7
|
|
|
|
|
3609
|
require Class::Inspector; |
78
|
|
|
|
|
|
|
|
79
|
7
|
50
|
|
|
|
21383
|
unless (@queue) { |
80
|
0
|
|
|
|
|
0
|
@queue = grep { $_ ne 'main' } |
|
0
|
|
|
|
|
0
|
|
81
|
|
|
|
|
|
|
Class::Inspector->_subnames(''); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
7
|
|
|
|
|
16
|
my @found; |
85
|
7
|
|
|
|
|
31
|
while (my $moniker = shift @queue) { |
86
|
7
|
|
|
|
|
44
|
my @subnames = Class::Inspector->_subnames($moniker); |
87
|
7
|
|
|
|
|
117
|
foreach my $subname (@subnames) { |
88
|
0
|
|
|
|
|
0
|
my $class = $moniker.'::'.$subname; |
89
|
0
|
0
|
0
|
|
|
0
|
push @found, $class if $class ne 'Test::Classy::Base' |
90
|
|
|
|
|
|
|
and $class->isa('Test::Classy::Base'); |
91
|
0
|
|
|
|
|
0
|
unshift @queue, $class; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
} |
94
|
7
|
|
|
|
|
22
|
return @found; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub plan { |
98
|
7
|
|
|
7
|
1
|
17
|
my $plan = 0; |
99
|
7
|
|
|
|
|
14
|
foreach my $test ( @tests ) { |
100
|
23
|
|
|
|
|
112
|
$plan += $test->_plan; |
101
|
|
|
|
|
|
|
} |
102
|
7
|
|
|
|
|
53
|
return $plan; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
1
|
|
|
1
|
1
|
4
|
sub reset { @tests = () } # for test |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
1; |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
__END__ |