File Coverage

blib/lib/List/Vectorize/lib/Datatype.pl
Criterion Covered Total %
statement 26 26 100.0
branch 18 18 100.0
condition 36 36 100.0
subroutine 8 8 100.0
pod 0 8 0.0
total 88 96 91.6


line stmt bran cond sub pod time code
1            
2             # description: is the scalar a number
3             sub is_numberic {
4 23     23 0 453 my $value = $_[0];
5 23 100       141 if($value =~/^-?\d+\.?\d*$/) {
6 16         121 return 1;
7             } else {
8 7         70 return 0;
9             }
10             }
11            
12             # description: is the scalar a array reference
13             sub is_array_ref {
14 4929 100 100 4929 0 32800 if($_[0] and ref($_[0])
      100        
15             and ref($_[0]) eq "ARRAY") {
16 4820         25373 return 1;
17             }
18             else {
19 109         410 return 0;
20             }
21             }
22            
23             # description: is the scalar a hash reference
24             sub is_hash_ref {
25 19 100 100 19 0 265 if($_[0] and ref($_[0])
      100        
26             and ref($_[0]) eq "HASH") {
27 8         99 return 1;
28             }
29             else {
30 11         61 return 0;
31             }
32             }
33            
34             # description: is the scalar a scalar reference
35             sub is_scalar_ref {
36 35 100 100 35 0 364 if($_[0] and ref($_[0])
      100        
37             and ref($_[0]) eq "SCALAR") {
38 24         102 return 1;
39             }
40             else {
41 11         51 return 0;
42             }
43             }
44            
45             # description: is the scalar a subroutiine reference
46             sub is_code_ref {
47 84 100 100 84 0 679 if($_[0] and ref($_[0])
      100        
48             and ref($_[0]) eq "CODE") {
49 13         60 return 1;
50             }
51             else {
52 71         250 return 0;
53             }
54             }
55            
56             # description: is the scalar a typeglob reference
57             sub is_glob_ref {
58 18 100 100 18 0 342 if($_[0] and ref($_[0])
      100        
59             and ref($_[0]) eq "GLOB") {
60 7         28 return 1;
61             }
62             else {
63 11         73 return 0;
64             }
65             }
66            
67             # description: is the scalar a reference reference
68             sub is_ref_ref {
69 146 100 100 146 0 1114 if($_[0] and ref($_[0])
      100        
70             and ref($_[0]) eq "REF") {
71 98         372 return 1;
72             }
73             else {
74 48         189 return 0;
75             }
76             }
77            
78             # description: the type of a scalar
79             sub type_of {
80            
81 7 100   7 0 25 if(ref($_[0])) {
    100          
82 4         18 return ref($_[0])."_REF";
83             }
84             elsif(ref(\$_[0]) eq "GLOB") {
85 2         9 return "GLOB";
86             }
87             else {
88 1         4 return "SCALAR";
89             }
90             }
91            
92             1;