line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
4
|
|
|
4
|
|
180102
|
use 5.008001; |
|
4
|
|
|
|
|
15
|
|
|
4
|
|
|
|
|
148
|
|
2
|
4
|
|
|
4
|
|
28
|
use strict; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
142
|
|
3
|
4
|
|
|
4
|
|
32
|
use warnings; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
141
|
|
4
|
4
|
|
|
4
|
|
25
|
no warnings qw( uninitialized void once ); |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
166
|
|
5
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
4764
|
use Devel::StrictMode (); |
|
4
|
|
|
|
|
1642
|
|
|
4
|
|
|
|
|
76
|
|
7
|
4
|
|
|
4
|
|
26
|
use Exporter::Tiny (); |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
2971
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
package PerlX::Assert; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TOBYINK'; |
12
|
|
|
|
|
|
|
our $VERSION = '0.903'; |
13
|
|
|
|
|
|
|
our @ISA = qw( Exporter::Tiny ); |
14
|
|
|
|
|
|
|
our @EXPORT = qw( assert ); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $NO_KEYWORD_API; |
17
|
|
|
|
|
|
|
my $IMPLEMENTATION; |
18
|
|
|
|
|
|
|
my %HINTS = (check => 1); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# This functionality probably needs to be added to |
21
|
|
|
|
|
|
|
# Exporter::Tiny itself. |
22
|
|
|
|
|
|
|
sub import |
23
|
|
|
|
|
|
|
{ |
24
|
9
|
|
|
9
|
|
970
|
my $me = shift; |
25
|
5
|
100
|
66
|
|
|
64
|
my $symbols = grep { |
|
|
100
|
|
|
|
|
|
26
|
9
|
|
|
|
|
15
|
ref($_) ? 0 : # refs are not symbols |
27
|
|
|
|
|
|
|
/\A[:-](\w+)\z/ && $HINTS{$1} ? 0 : # hints are not symbols |
28
|
|
|
|
|
|
|
1; # everything else is |
29
|
|
|
|
|
|
|
} @_; |
30
|
|
|
|
|
|
|
|
31
|
9
|
100
|
|
|
|
42
|
push @_, @EXPORT if $symbols == 0; |
32
|
|
|
|
|
|
|
|
33
|
9
|
50
|
|
|
|
29
|
my $globals = ref($_[0]) eq 'HASH' ? shift() : {}; |
34
|
9
|
|
|
|
|
24
|
unshift @_, $me, $globals; |
35
|
9
|
|
|
|
|
48
|
goto \&Exporter::Tiny::import; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub _exporter_validate_opts |
39
|
|
|
|
|
|
|
{ |
40
|
9
|
|
|
9
|
|
512
|
my $me = shift; |
41
|
9
|
|
|
|
|
13
|
my ($globals) = @_; |
42
|
|
|
|
|
|
|
|
43
|
9
|
50
|
0
|
|
|
32
|
$IMPLEMENTATION ||= $me unless $me eq __PACKAGE__; |
44
|
|
|
|
|
|
|
$IMPLEMENTATION ||= eval { |
45
|
|
|
|
|
|
|
die if $NO_KEYWORD_API; |
46
|
|
|
|
|
|
|
require PerlX::Assert::Keyword; |
47
|
|
|
|
|
|
|
'PerlX::Assert::Keyword'; |
48
|
|
|
|
|
|
|
} |
49
|
9
|
|
33
|
|
|
25
|
|| do { |
|
|
|
66
|
|
|
|
|
50
|
|
|
|
|
|
|
require PerlX::Assert::DD; |
51
|
|
|
|
|
|
|
'PerlX::Assert::DD'; |
52
|
|
|
|
|
|
|
}; |
53
|
|
|
|
|
|
|
|
54
|
9
|
|
|
|
|
37
|
++$globals->{check} if Devel::StrictMode::STRICT; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub _exporter_install_sub |
58
|
|
|
|
|
|
|
{ |
59
|
9
|
|
|
9
|
|
84
|
my $me = shift; |
60
|
9
|
|
|
|
|
19
|
my ($name, $value, $globals, $sym) = @_; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# This is harder than it should be. :-( |
63
|
|
|
|
|
|
|
# A rather roundabout method for overwriting |
64
|
|
|
|
|
|
|
# the installation of the 'assert' function. |
65
|
9
|
50
|
33
|
|
|
90
|
if ($name eq 'assert' and not ref $globals->{into}) |
66
|
|
|
|
|
|
|
{ |
67
|
9
|
50
|
|
|
|
36
|
my $tmp = exists($globals->{installer}) |
68
|
|
|
|
|
|
|
? [ delete($globals->{installer}) ] |
69
|
|
|
|
|
|
|
: undef; |
70
|
|
|
|
|
|
|
$globals->{installer} = sub { |
71
|
9
|
|
|
9
|
|
257
|
$IMPLEMENTATION->_install_assert( |
72
|
|
|
|
|
|
|
$_[1][0], |
73
|
|
|
|
|
|
|
$globals, |
74
|
|
|
|
|
|
|
); |
75
|
9
|
|
|
|
|
64
|
}; |
76
|
9
|
|
|
|
|
67
|
$me->SUPER::_exporter_install_sub(@_); |
77
|
9
|
50
|
|
|
|
455
|
$tmp |
78
|
|
|
|
|
|
|
? ($globals->{installer} = $tmp->[0]) |
79
|
|
|
|
|
|
|
: delete($globals->{installer}); |
80
|
9
|
|
|
|
|
31
|
return; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
0
|
$me->SUPER::_exporter_install_sub(@_); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub _generate_assert |
87
|
|
|
|
|
|
|
{ |
88
|
13
|
|
|
13
|
|
779
|
my $me = shift; |
89
|
13
|
|
|
|
|
45
|
my ($name, $args, $globals) = @_; |
90
|
|
|
|
|
|
|
|
91
|
0
|
|
|
0
|
|
0
|
return sub ($$) { 0 } |
92
|
13
|
100
|
|
|
|
110
|
unless $globals->{check}; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
return sub ($$) { |
95
|
0
|
0
|
|
0
|
|
|
my ($desc, $value) = @_==1 ? (undef, @_) : @_; |
96
|
0
|
0
|
|
|
|
|
return if $value; |
97
|
0
|
|
|
|
|
|
require Carp; |
98
|
0
|
0
|
|
|
|
|
Carp::croak(sprintf(q[Assertion failed: %s], $desc)) if defined $desc; |
99
|
0
|
|
|
|
|
|
Carp::croak(sprintf(q[Assertion failed])); |
100
|
3
|
|
|
|
|
45
|
}; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
*assert = __PACKAGE__->_generate_assert(assert => {}, {}); |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
__PACKAGE__ |
106
|
|
|
|
|
|
|
__END__ |