line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Mockify::TypeTests; |
2
|
9
|
|
|
9
|
|
93887
|
use strict; |
|
9
|
|
|
|
|
10
|
|
|
9
|
|
|
|
|
224
|
|
3
|
9
|
|
|
9
|
|
28
|
use Scalar::Util qw ( blessed ); |
|
9
|
|
|
|
|
10
|
|
|
9
|
|
|
|
|
510
|
|
4
|
9
|
|
|
9
|
|
39
|
use base qw( Exporter ); |
|
9
|
|
|
|
|
8
|
|
|
9
|
|
|
|
|
766
|
|
5
|
|
|
|
|
|
|
our @EXPORT_OK = qw ( |
6
|
|
|
|
|
|
|
IsInteger |
7
|
|
|
|
|
|
|
IsFloat |
8
|
|
|
|
|
|
|
IsString |
9
|
|
|
|
|
|
|
IsArrayReference |
10
|
|
|
|
|
|
|
IsHashReference |
11
|
|
|
|
|
|
|
IsObjectReference |
12
|
|
|
|
|
|
|
); |
13
|
|
|
|
|
|
|
|
14
|
9
|
|
|
9
|
|
31
|
use Test::More; |
|
9
|
|
|
|
|
20
|
|
|
9
|
|
|
|
|
48
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub IsInteger { |
17
|
22
|
|
|
22
|
0
|
433
|
my ( $Value ) = @_; |
18
|
|
|
|
|
|
|
|
19
|
22
|
|
|
|
|
20
|
my $IsInteger = 0; |
20
|
22
|
|
|
|
|
22
|
my $Sign = '[-+]?'; |
21
|
|
|
|
|
|
|
|
22
|
22
|
100
|
|
|
|
476
|
if( $Value =~ /^$Sign\d+$/ ) { |
23
|
11
|
|
|
|
|
12
|
$IsInteger = 1; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
22
|
|
|
|
|
85
|
return $IsInteger; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub IsFloat { |
30
|
59
|
|
|
59
|
0
|
462
|
my ( $Value ) = @_; |
31
|
|
|
|
|
|
|
|
32
|
59
|
|
|
|
|
54
|
my $IsFloat = 0; |
33
|
|
|
|
|
|
|
|
34
|
59
|
|
|
|
|
48
|
my $OptionalSign = '[-+]?'; |
35
|
59
|
|
|
|
|
46
|
my $NumberOptions = '(?=\d|\.\d)\d*(\.\d*)?'; |
36
|
59
|
|
|
|
|
39
|
my $OptionalExponent = '([eE][-+]?\d+)?'; |
37
|
59
|
|
|
|
|
139
|
my $FloatRegex = sprintf('%s%s%s', $OptionalSign, $NumberOptions, $OptionalExponent); |
38
|
|
|
|
|
|
|
|
39
|
59
|
100
|
|
|
|
694
|
if ( $Value =~ /^$FloatRegex$/ ){ |
40
|
49
|
|
|
|
|
48
|
$IsFloat = 1; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
59
|
|
|
|
|
246
|
return $IsFloat; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub IsString { |
47
|
29
|
|
|
29
|
0
|
428
|
my ( $Value ) = @_; |
48
|
|
|
|
|
|
|
|
49
|
29
|
|
|
|
|
25
|
my $IsString = 0; |
50
|
|
|
|
|
|
|
|
51
|
29
|
100
|
|
|
|
47
|
if ( defined $Value ){ |
52
|
28
|
50
|
66
|
|
|
136
|
if( $Value =~ /[\w\s]/ || $Value eq ''){ |
53
|
28
|
|
|
|
|
23
|
$IsString = 1; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
28
|
|
|
|
|
27
|
my $ValueType = ref( $Value ); |
57
|
28
|
100
|
66
|
|
|
109
|
if( defined $ValueType && $ValueType ne '' ) { |
58
|
5
|
|
|
|
|
4
|
$IsString = 0; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
29
|
|
|
|
|
86
|
return $IsString; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub IsArrayReference { |
66
|
44
|
|
|
44
|
0
|
446
|
my ( $aValue ) = @_; |
67
|
|
|
|
|
|
|
|
68
|
44
|
|
|
|
|
34
|
my $IsArray = 0; |
69
|
|
|
|
|
|
|
|
70
|
44
|
100
|
|
|
|
101
|
if ( ref($aValue) eq 'ARRAY' ) { |
71
|
34
|
|
|
|
|
33
|
$IsArray = 1; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
44
|
|
|
|
|
117
|
return $IsArray; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub IsHashReference { |
78
|
102
|
|
|
102
|
0
|
451
|
my ( $hValue ) = @_; |
79
|
|
|
|
|
|
|
|
80
|
102
|
|
|
|
|
63
|
my $IsHash = 0; |
81
|
|
|
|
|
|
|
|
82
|
102
|
100
|
|
|
|
156
|
if ( ref($hValue) eq 'HASH' ) { |
83
|
46
|
|
|
|
|
41
|
$IsHash = 1; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
102
|
|
|
|
|
220
|
return $IsHash; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub IsObjectReference { |
90
|
16
|
|
|
16
|
0
|
425
|
my ( $Value ) = @_; |
91
|
|
|
|
|
|
|
|
92
|
16
|
|
|
|
|
14
|
my $IsObject = 0; |
93
|
|
|
|
|
|
|
|
94
|
16
|
100
|
|
|
|
49
|
if( blessed( $Value ) ) { |
95
|
8
|
|
|
|
|
8
|
$IsObject = 1; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
16
|
|
|
|
|
55
|
return $IsObject; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
1; |
101
|
|
|
|
|
|
|
|