| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package assertions::compat; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
require assertions; |
|
6
|
|
|
|
|
|
|
our @ISA = qw(assertions); |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub _on () { 1 } |
|
9
|
|
|
|
|
|
|
sub _off () { 0 } |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub import { |
|
12
|
6
|
|
|
6
|
|
33
|
my $class = shift; |
|
13
|
6
|
50
|
|
|
|
12
|
my $name = @_ ? shift : 'asserting'; |
|
14
|
6
|
|
|
|
|
9
|
my $pkg = caller; |
|
15
|
6
|
50
|
|
|
|
23
|
$name =~ /::/ or $name = "${pkg}::${name}"; |
|
16
|
6
|
50
|
|
|
|
13
|
@_ = $pkg unless @_; |
|
17
|
6
|
|
|
|
|
25
|
$class->SUPER::import(@_); |
|
18
|
6
|
|
|
|
|
15
|
my $enabled = assertions::enabled(); |
|
19
|
|
|
|
|
|
|
{ |
|
20
|
2
|
|
|
2
|
|
1796
|
no strict 'vars'; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
64
|
|
|
|
6
|
|
|
|
|
8
|
|
|
21
|
2
|
|
|
2
|
|
10
|
no warnings; |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
433
|
|
|
22
|
6
|
|
|
|
|
7
|
undef &{$name}; |
|
|
6
|
|
|
|
|
43
|
|
|
23
|
6
|
100
|
|
|
|
15
|
*{$name} = $enabled ? \&_on : \&_off; |
|
|
6
|
|
|
|
|
1971
|
|
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
} |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub _compat_assertion_handler { |
|
28
|
3
|
|
|
3
|
|
416
|
shift; shift; |
|
|
3
|
|
|
|
|
5
|
|
|
29
|
3
|
|
|
|
|
12
|
grep $_ ne 'assertion', @_ |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
|
|
32
|
0
|
|
|
0
|
|
|
sub _do_nothing_handler {} |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# test if 'assertion' attribute is natively supported |
|
35
|
2
|
|
|
2
|
|
1881
|
my $assertion_ok=eval q{ |
|
|
2
|
|
|
0
|
|
2937
|
|
|
|
2
|
|
|
|
|
12
|
|
|
|
0
|
|
|
|
|
0
|
|
|
36
|
|
|
|
|
|
|
sub _my_asserting_test : assertion { 1 } |
|
37
|
|
|
|
|
|
|
_my_asserting_test() |
|
38
|
|
|
|
|
|
|
}; |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
*MODIFY_CODE_ATTRIBUTES = |
|
41
|
|
|
|
|
|
|
defined($assertion_ok) |
|
42
|
|
|
|
|
|
|
? \&_do_nothing_handler |
|
43
|
|
|
|
|
|
|
: \&_compat_assertion_handler; |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
*supported = |
|
46
|
|
|
|
|
|
|
defined($assertion_ok) |
|
47
|
|
|
|
|
|
|
? \&_on |
|
48
|
|
|
|
|
|
|
: \&_off; |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
unless (defined $assertion_ok) { |
|
51
|
|
|
|
|
|
|
package assertions; |
|
52
|
|
|
|
|
|
|
require warnings::register; |
|
53
|
|
|
|
|
|
|
warnings::register->import; |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
__END__ |