line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Chai::Util::Property; |
2
|
6
|
|
|
6
|
|
79813
|
use strict; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
155
|
|
3
|
6
|
|
|
6
|
|
28
|
use warnings; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
142
|
|
4
|
6
|
|
|
6
|
|
29
|
use utf8; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
37
|
|
5
|
|
|
|
|
|
|
|
6
|
6
|
|
|
6
|
|
139
|
use Exporter qw/import/; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
328
|
|
7
|
|
|
|
|
|
|
our @EXPORT_OK = qw/has_property/; |
8
|
|
|
|
|
|
|
|
9
|
6
|
|
|
6
|
|
4331
|
use List::MoreUtils qw/any/; |
|
6
|
|
|
|
|
62032
|
|
|
6
|
|
|
|
|
83
|
|
10
|
6
|
|
|
6
|
|
4058
|
use Scalar::Util qw/looks_like_number blessed/; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
1590
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub has_property { |
13
|
75
|
|
|
75
|
0
|
6623
|
my ($name, $obj) = @_; |
14
|
|
|
|
|
|
|
|
15
|
75
|
100
|
|
|
|
211
|
return 0 unless defined $obj; |
16
|
|
|
|
|
|
|
|
17
|
67
|
100
|
100
|
|
|
394
|
if (ref $obj eq 'ARRAY') { |
|
|
100
|
66
|
|
|
|
|
|
|
100
|
66
|
|
|
|
|
|
|
100
|
|
|
|
|
|
18
|
16
|
100
|
|
|
|
73
|
return 0 unless looks_like_number($name); |
19
|
15
|
100
|
100
|
|
|
113
|
return 1 if 0 <= $name && $name < @$obj; |
20
|
6
|
|
|
|
|
23
|
return 0; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
elsif (ref $obj eq 'HASH' || blessed($obj)) { |
24
|
41
|
100
|
|
|
|
95
|
return 0 unless defined $name; |
25
|
39
|
100
|
|
45
|
|
324
|
return 1 if any { $_ eq $name } keys(%$obj); |
|
45
|
|
|
|
|
206
|
|
26
|
7
|
|
|
|
|
39
|
return 0; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
elsif (looks_like_number($name)) { |
30
|
2
|
100
|
66
|
|
|
19
|
return 1 if 0 <= $name && $name < length $obj; |
31
|
1
|
|
|
|
|
5
|
return 0; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
elsif ($name eq 'length' && defined $obj && !ref $obj) { |
35
|
5
|
|
|
|
|
15
|
return 1; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
3
|
|
|
|
|
9
|
return 0; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |