line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Mockify::TypeTests; |
2
|
17
|
|
|
17
|
|
128922
|
use strict; |
|
17
|
|
|
|
|
25
|
|
|
17
|
|
|
|
|
483
|
|
3
|
17
|
|
|
17
|
|
79
|
use warnings; |
|
17
|
|
|
|
|
723
|
|
|
17
|
|
|
|
|
1188
|
|
4
|
17
|
|
|
17
|
|
68
|
use Scalar::Util qw ( blessed ); |
|
17
|
|
|
|
|
26
|
|
|
17
|
|
|
|
|
1221
|
|
5
|
17
|
|
|
17
|
|
77
|
use base qw( Exporter ); |
|
17
|
|
|
|
|
22
|
|
|
17
|
|
|
|
|
8317
|
|
6
|
|
|
|
|
|
|
our @EXPORT_OK = qw ( |
7
|
|
|
|
|
|
|
IsInteger |
8
|
|
|
|
|
|
|
IsFloat |
9
|
|
|
|
|
|
|
IsString |
10
|
|
|
|
|
|
|
IsArrayReference |
11
|
|
|
|
|
|
|
IsHashReference |
12
|
|
|
|
|
|
|
IsObjectReference |
13
|
|
|
|
|
|
|
IsCodeReference |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub IsInteger { |
18
|
17
|
|
|
17
|
0
|
167
|
my ( $Value ) = @_; |
19
|
|
|
|
|
|
|
|
20
|
17
|
|
|
|
|
15
|
my $IsInteger = 0; |
21
|
17
|
|
|
|
|
12
|
my $Sign = '[-+]?'; |
22
|
17
|
100
|
|
|
|
33
|
if( defined $Value ){ |
23
|
16
|
100
|
|
|
|
137
|
if($Value =~ /^$Sign\d+$/ ) { |
24
|
7
|
|
|
|
|
9
|
$IsInteger = 1; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
17
|
|
|
|
|
63
|
return $IsInteger; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub IsFloat { |
32
|
154
|
|
|
154
|
0
|
567
|
my ( $Value ) = @_; |
33
|
|
|
|
|
|
|
|
34
|
154
|
|
|
|
|
119
|
my $IsFloat = 0; |
35
|
|
|
|
|
|
|
|
36
|
154
|
|
|
|
|
134
|
my $OptionalSign = '[-+]?'; |
37
|
154
|
|
|
|
|
124
|
my $NumberOptions = '(?=\d|\.\d)\d*(\.\d*)?'; |
38
|
154
|
|
|
|
|
99
|
my $OptionalExponent = '([eE][-+]?\d+)?'; |
39
|
154
|
|
|
|
|
388
|
my $FloatRegex = sprintf('%s%s%s', $OptionalSign, $NumberOptions, $OptionalExponent); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
42
|
154
|
100
|
100
|
|
|
1952
|
if ( $Value && $Value =~ /^$FloatRegex$/ ){ |
43
|
76
|
|
|
|
|
69
|
$IsFloat = 1; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
154
|
|
|
|
|
577
|
return $IsFloat; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub IsString { |
50
|
170
|
|
|
170
|
0
|
337
|
my ( $Value ) = @_; |
51
|
|
|
|
|
|
|
|
52
|
170
|
|
|
|
|
130
|
my $IsString = 0; |
53
|
|
|
|
|
|
|
|
54
|
170
|
100
|
|
|
|
265
|
if ( defined $Value ){ |
55
|
160
|
50
|
66
|
|
|
533
|
if( $Value =~ /[\w\s]/ || $Value eq ''){ |
56
|
160
|
|
|
|
|
136
|
$IsString = 1; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
160
|
|
|
|
|
144
|
my $ValueType = ref( $Value ); |
60
|
160
|
100
|
66
|
|
|
581
|
if( defined $ValueType && $ValueType ne '' ) { |
61
|
5
|
|
|
|
|
8
|
$IsString = 0; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
170
|
|
|
|
|
620
|
return $IsString; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub IsArrayReference { |
69
|
171
|
|
|
171
|
0
|
680
|
my ( $aValue ) = @_; |
70
|
|
|
|
|
|
|
|
71
|
171
|
|
|
|
|
130
|
my $IsArray = 0; |
72
|
|
|
|
|
|
|
|
73
|
171
|
100
|
|
|
|
315
|
if ( ref($aValue) eq 'ARRAY' ) { |
74
|
46
|
|
|
|
|
47
|
$IsArray = 1; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
171
|
|
|
|
|
420
|
return $IsArray; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub IsHashReference { |
81
|
133
|
|
|
133
|
0
|
280
|
my ( $hValue ) = @_; |
82
|
|
|
|
|
|
|
|
83
|
133
|
|
|
|
|
119
|
my $IsHash = 0; |
84
|
|
|
|
|
|
|
|
85
|
133
|
100
|
|
|
|
220
|
if ( ref($hValue) eq 'HASH' ) { |
86
|
21
|
|
|
|
|
24
|
$IsHash = 1; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
133
|
|
|
|
|
313
|
return $IsHash; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub IsCodeReference { |
93
|
95
|
|
|
95
|
0
|
514
|
my ( $hValue ) = @_; |
94
|
|
|
|
|
|
|
|
95
|
95
|
|
|
|
|
80
|
my $IsCode = 0; |
96
|
|
|
|
|
|
|
|
97
|
95
|
100
|
|
|
|
142
|
if ( ref($hValue) eq 'CODE' ) { |
98
|
5
|
|
|
|
|
7
|
$IsCode = 1; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
95
|
|
|
|
|
187
|
return $IsCode; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub IsObjectReference { |
105
|
111
|
|
|
111
|
0
|
240
|
my ( $Value ) = @_; |
106
|
|
|
|
|
|
|
|
107
|
111
|
|
|
|
|
89
|
my $IsObject = 0; |
108
|
|
|
|
|
|
|
|
109
|
111
|
100
|
|
|
|
265
|
if( blessed( $Value ) ) { |
110
|
14
|
|
|
|
|
14
|
$IsObject = 1; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
111
|
|
|
|
|
237
|
return $IsObject; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
1; |
117
|
|
|
|
|
|
|
|