File Coverage

lib/String/Numeric/Regexp.pm
Criterion Covered Total %
statement 13 13 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 16 16 100.0


line stmt bran cond sub pod time code
1             package String::Numeric::Regexp;
2 6     6   34 use strict;
  6         12  
  6         206  
3 6     6   133 use warnings;
  6         11  
  6         1281  
4              
5             BEGIN {
6 6     6   16 our $VERSION = '0.9_01';
7 6         25 our @EXPORT_OK = qw(
8             $Float_re
9             $Decimal_re
10             $Numeric_re
11             $Int_re
12             $Int8_re
13             $Int16_re
14             $Int32_re
15             $Int64_re
16             $UInt_re
17             $UInt8_re
18             $UInt16_re
19             $UInt32_re
20             $UInt64_re
21             );
22              
23 78         176 our %EXPORT_TAGS = (
24             all => [ @EXPORT_OK ],
25 78         160 int => [ grep { /^\$Int/ } @EXPORT_OK ],
26 6         25 uint => [ grep { /^\$UInt/ } @EXPORT_OK ],
27             );
28              
29 6         35 require Exporter;
30 6         14404 *import = \&Exporter::import;
31             }
32              
33             our $Float_re = qr<-?(?:0|[1-9][0-9]*)(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?>;
34             our $Decimal_re = qr<-?(?:0|[1-9][0-9]*)(?:\.[0-9]+)?>;
35             our $Numeric_re = $Float_re;
36              
37             our $UInt_re = qr<0|[1-9][0-9]*>;
38              
39             # 0 to 127
40             our $UInt7_re = qr<
41             0
42             | [1-9][0-9]{0,1}
43             | 1 (?: [0-1][0-9]
44             | | 2 [0-7])
45             >x;
46              
47             # 0 to 255
48             our $UInt8_re = qr<
49             0
50             | 1 [0-9]{0,2}
51             | [2-9][0-9]{0,1}
52             | 2 (?: [0-4][0-9]
53             | 5 [0-5])
54             >x;
55              
56             # 0 to 32,767
57             our $UInt15_re = qr<
58             0
59             | [1-2][0-9]{0,4}
60             | [3-9][0-9]{0,3}
61             | 3 (?: [0-1][0-9]{3}
62             | 2 (?: [0-6][0-9]{2}
63             | 7 (?: [0-5][0-9]
64             | 6 [0-7])))
65             >x;
66              
67             # 0 to 65,535
68             our $UInt16_re = qr<
69             0
70             | [1-5][0-9]{0,4}
71             | [6-9][0-9]{0,3}
72             | 6 (?: [0-4][0-9]{3}
73             | 5 (?: [0-4][0-9]{2}
74             | 5 (?: [0-2][0-9]
75             | 3 [0-5])))
76             >x;
77              
78             # 0 to 2,147,483,647
79             our $UInt31_re = qr<
80             0
81             | 1 [0-9]{0,9}
82             | [2-9][0-9]{0,8}
83             | 2 (?: 0 [0-9]{8}
84             | 1 (?: [0-3][0-9]{7}
85             | 4 (?: [0-6][0-9]{6}
86             | 7 (?: [0-3][0-9]{5}
87             | 4 (?: [0-7][0-9]{4}
88             | 8 (?: [0-2][0-9]{3}
89             | 3 (?: [0-5][0-9]{2}
90             | 6 (?: [0-3][0-9]
91             | 4 [0-7]))))))))
92             >x;
93              
94             # 0 to 4,294,967,295
95             our $UInt32_re = qr<
96             0
97             | [1-3][0-9]{0,9}
98             | [4-9][0-9]{0,8}
99             | 4 (?: [0-1][0-9]{8}
100             | 2 (?: [0-8][0-9]{7}
101             | 9 (?: [0-3][0-9]{6}
102             | 4 (?: [0-8][0-9]{5}
103             | 9 (?: [0-5][0-9]{4}
104             | 6 (?: [0-6][0-9]{3}
105             | 7 (?: [0-1][0-9]{2}
106             | 2 (?: [0-8][0-9]
107             | 9 [0-5]))))))))
108             >x;
109              
110             # 0 to 9,223,372,036,854,775,807
111             our $UInt63_re = qr<
112             0
113             | [1-8][0-9]{0,18}
114             | 9 [0-9]{0,17}
115             | 9 (?: [0-1][0-9]{17}
116             | 2 (?: [0-1][0-9]{16}
117             | 2 (?: [0-2][0-9]{15}
118             | 3 (?: [0-2][0-9]{14}
119             | 3 (?: [0-6][0-9]{13}
120             | 7 (?: [0-1][0-9]{12}
121             | 20 (?: [0-2][0-9]{10}
122             | 3 (?: [0-5][0-9]{9}
123             | 6 (?: [0-7][0-9]{8}
124             | 8 (?: [0-4][0-9]{7}
125             | 5 (?: [0-3][0-9]{6}
126             | 4 (?: [0-6][0-9]{5}
127             | 7 (?: [0-6][0-9]{4}
128             | 7 (?: [0-4][0-9]{3}
129             | 5 (?: [0-7][0-9]{2}
130             | 80 [0-7])))))))))))))))
131             >x;
132              
133             # 0 to 18,446,744,073,709,551,615
134             our $UInt64_re = qr<
135             0
136             | [1-9][0-9]{0,18}
137             | 1 (?: [0-7][0-9]{18}
138             | 8 (?: [0-3][0-9]{17}
139             | 4 (?: [0-3][0-9]{16}
140             | 4 (?: [0-5][0-9]{15}
141             | 6 (?: [0-6][0-9]{14}
142             | 7 (?: [0-3][0-9]{13}
143             | 4 (?: [0-3][0-9]{12}
144             | 40 (?: [0-6][0-9]{10}
145             | 7 (?: [0-2][0-9]{9}
146             | 3 (?: [0-6][0-9]{8}
147             | 70 (?: [0-8][0-9]{6}
148             | 9 (?: [0-4][0-9]{5}
149             | 5 (?: [0-4][0-9]{4}
150             | 5 (?: 0 [0-9]{3}
151             | 1 (?: [0-5][0-9]{2}
152             | 6 (?: 0 [0-9]
153             | 1 [0-5]))))))))))))))))
154             >x;
155              
156             our $Int_re = qr<-?(?:0|[1-9][0-9]*)>;
157              
158             # −128 to 127
159             our $Int8_re = qr<(?: - (?: $UInt7_re | 128 )) | $UInt7_re>x;
160              
161             # −32,768 to 32,767
162             our $Int16_re = qr<(?: - (?: $UInt15_re | 32768 )) | $UInt15_re>x;
163              
164             # −2,147,483,648 to 2,147,483,647
165             our $Int32_re = qr<(?: - (?: $UInt31_re | 2147483648 )) | $UInt31_re>x;
166              
167             # −9,223,372,036,854,775,808 to +9,223,372,036,854,775,807
168             our $Int64_re = qr<(?: - (?: $UInt63_re | 9223372036854775808 )) | $UInt63_re>x;
169              
170             1;
171              
172             __END__