line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Attribute::AutoLevel; |
2
|
3
|
|
|
3
|
|
84529
|
use strict; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
112
|
|
3
|
3
|
|
|
3
|
|
15
|
use warnings; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
80
|
|
4
|
3
|
|
|
3
|
|
76
|
use 5.008001; |
|
3
|
|
|
|
|
15
|
|
|
3
|
|
|
|
|
328
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.06'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub import { |
8
|
3
|
|
|
3
|
|
27
|
my ($class, %args) = @_; |
9
|
3
|
|
100
|
|
|
27
|
my $caller = caller($args{depth} || 0); |
10
|
|
|
|
|
|
|
|
11
|
3
|
|
|
3
|
|
16
|
no strict 'refs'; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
747
|
|
12
|
3
|
|
|
|
|
6
|
*{"${caller}::MODIFY_CODE_ATTRIBUTES"} = \&_MODIFY_CODE_ATTRIBUTES; |
|
3
|
|
|
|
|
92
|
|
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my $stash = {}; |
16
|
|
|
|
|
|
|
sub _fake { |
17
|
6
|
|
|
6
|
|
8
|
my ($pkg, $code) = @_; |
18
|
|
|
|
|
|
|
|
19
|
6
|
|
100
|
|
|
30
|
$stash->{$pkg} ||= {}; |
20
|
|
|
|
|
|
|
my $fake = sub { |
21
|
6
|
|
|
6
|
|
2622
|
local $Test::Builder::Level = $Test::Builder::Level + 2; |
22
|
6
|
|
|
|
|
23
|
$code->(@_); |
23
|
6
|
|
|
|
|
24
|
}; |
24
|
6
|
|
|
|
|
25
|
$stash->{$pkg}{"$code"} = $fake; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub _MODIFY_CODE_ATTRIBUTES { |
28
|
6
|
|
|
6
|
|
5979
|
my ($pkg, $code, @attrs) = @_; |
29
|
6
|
50
|
|
|
|
18
|
return unless $attrs[0] eq 'AutoLevel'; |
30
|
6
|
|
|
|
|
31
|
_fake($pkg, $code); |
31
|
6
|
|
|
|
|
17
|
return; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub CHECK { |
35
|
3
|
|
|
3
|
|
5826
|
my $pkg = caller; |
36
|
3
|
100
|
|
|
|
1231
|
return unless exists $stash->{$pkg}; |
37
|
|
|
|
|
|
|
|
38
|
3
|
|
|
3
|
|
18
|
no strict 'refs'; |
|
3
|
|
|
|
|
11
|
|
|
3
|
|
|
|
|
278
|
|
39
|
2
|
|
|
|
|
12
|
for my $name (keys %{"$pkg\::"}) { |
|
2
|
|
|
|
|
311
|
|
40
|
460
|
|
100
|
2
|
|
399
|
my $code = *{"${pkg}::${name}"}{CODE} || next; |
|
2
|
|
|
|
|
2308
|
|
|
2
|
|
|
|
|
2888
|
|
|
2
|
|
|
|
|
23
|
|
41
|
62
|
|
100
|
|
|
247
|
my $fake = $stash->{$pkg}{"$code"} || next; |
42
|
3
|
|
|
3
|
|
16
|
no warnings 'redefine'; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
260
|
|
43
|
6
|
|
|
|
|
8
|
*{"${pkg}::${name}"} = $fake; |
|
6
|
|
|
|
|
25
|
|
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
2
|
|
|
|
|
220266
|
delete $stash->{$pkg}; # cleanup |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
__END__ |