line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Contextual::Diag; |
2
|
2
|
|
|
2
|
|
194250
|
use 5.010; |
|
2
|
|
|
|
|
10
|
|
3
|
2
|
|
|
2
|
|
10
|
use strict; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
34
|
|
4
|
2
|
|
|
2
|
|
14
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
87
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = "0.02"; |
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
11
|
use Exporter; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
118
|
|
9
|
|
|
|
|
|
|
our @ISA = qw/Exporter/; |
10
|
|
|
|
|
|
|
our @EXPORT = qw/contextual_diag/; |
11
|
|
|
|
|
|
|
|
12
|
2
|
|
|
2
|
|
1459
|
use Contextual::Return; |
|
2
|
|
|
|
|
27680
|
|
|
2
|
|
|
|
|
13
|
|
13
|
2
|
|
|
2
|
|
2969
|
use Carp (); |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
529
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub contextual_diag { |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# XXX: SCALAR block is lazy. |
18
|
|
|
|
|
|
|
# https://metacpan.org/pod/Contextual%3A%3AReturn#Lazy-contextual-return-values |
19
|
34
|
100
|
100
|
34
|
1
|
42367
|
if (defined wantarray && !wantarray) { |
20
|
23
|
|
|
|
|
44
|
_diag('wanted SCALAR context'); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
return |
24
|
1
|
|
|
1
|
|
1122
|
VOID { _diag('wanted VOID context'); @_ } |
|
1
|
|
|
|
|
102
|
|
25
|
10
|
|
|
10
|
|
6608
|
LIST { _diag('wanted LIST context'); @_ } |
|
10
|
|
|
|
|
709
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# Scalar Value |
28
|
1
|
|
|
1
|
|
754
|
BOOL { _diag('evaluated as BOOL in SCALAR context'); $_[0] } |
|
1
|
|
|
|
|
113
|
|
29
|
2
|
100
|
|
2
|
|
1338
|
NUM { _diag('evaluated as NUM in SCALAR context'); $_[0] || 0 } |
|
2
|
|
|
|
|
129
|
|
30
|
3
|
100
|
|
3
|
|
2013
|
STR { _diag('evaluated as STR in SCALAR context'); $_[0] || "" } |
|
3
|
|
|
|
|
200
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# Scalar Reference |
33
|
2
|
100
|
|
2
|
|
1387
|
SCALARREF { _diag('scalar ref is evaluated as SCALARREF'); defined $_[0] ? $_[0] : \"" } |
|
2
|
|
|
|
|
127
|
|
34
|
3
|
100
|
|
3
|
|
2047
|
ARRAYREF { _diag('scalar ref is evaluated as ARRAYREF'); defined $_[0] ? $_[0] : [] } |
|
3
|
|
|
|
|
187
|
|
35
|
3
|
100
|
|
3
|
|
2060
|
HASHREF { _diag('scalar ref is evaluated as HASHREF'); defined $_[0] ? $_[0] : {} } |
|
3
|
|
|
|
|
189
|
|
36
|
2
|
100
|
|
2
|
|
1335
|
CODEREF { _diag('scalar ref is evaluated as CODEREF'); defined $_[0] ? $_[0] : sub { } } |
|
2
|
|
|
|
|
125
|
|
37
|
2
|
100
|
|
2
|
|
13
|
GLOBREF { _diag('scalar ref is evaluated as GLOBREF'); defined $_[0] ? $_[0] : do { no strict qw/refs/; my $package = __PACKAGE__; \*{$package} } } |
|
2
|
|
|
2
|
|
4
|
|
|
2
|
|
|
|
|
286
|
|
|
2
|
|
|
|
|
1370
|
|
|
2
|
|
|
|
|
126
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
38
|
2
|
100
|
|
2
|
|
1378
|
OBJREF { _diag('scalar ref is evaluated as OBJREF'); defined $_[0] ? $_[0] : bless {}, __PACKAGE__ } |
|
2
|
|
|
|
|
125
|
|
39
|
34
|
|
|
|
|
4151
|
; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub _diag { |
43
|
54
|
|
|
54
|
|
76
|
local $Carp::CarpLevel = 2; |
44
|
54
|
|
|
|
|
172
|
goto &Carp::carp; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |
48
|
|
|
|
|
|
|
__END__ |