blib/lib/Scalar/Util/Numeric/PP.pm

filter: Statementstmt 100% 40 / 40 Branchbran 100% 28 / 28 Conditioncond 91.6% 11 / 12 MC/DCmcdc 83.3% 5 / 6 Subroutinesub 100% 9 / 9 Podpod 100% 6 / 6 totaltotal 98.0% 99 / 101 CC 19 SCAR 14.8
CC
19
Cov
99%
isfloat
8.0
isnum
4.0
isint
3.0
CRAP 4.4
↑ Summary
1 package Scalar::Util::Numeric::PP;
2  
3 2 our $DATE = '2016-01-22'; # DATE
4 2 our $VERSION = '0.04'; # VERSION
5  
6 2 ▶use 5.010001;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 require Exporter;
11 2 our @ISA = qw(Exporter);
12 2 our @EXPORT_OK = qw(
13 isint
14 isnum
15 isnan
16 isinf
17 isneg
18 isfloat
19 );
20  
21 22 ▶sub isint {
Subroutine isint: called CC=3 SCAR=11.0
Pod documented
22 22 local $_ = shift;
23 22 ▶ return 0 unless defined;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_ 1 21 22
24 21 ▶ return 1 if /\A\s*[+-]?(?:0|[1-9][0-9]*)\s*\z/s;
Branch: 1 branch
BranchTrueFalseTotal
if /\A\s*[+-]?(?:0|[1-9][0-9]*)\s*\z/s 9 12 21
25 12 0;
26 }
27  
28 21 ▶sub isnan($) {
Subroutine isnan: called CC=3 SCAR=11.0
Pod documented
29 21 local $_ = shift;
30 21 ▶ return 0 unless defined;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_ 1 20 21
31 20 ▶ return 1 if /\A\s*[+-]?nan\s*\z/is;
Branch: 1 branch
BranchTrueFalseTotal
if /\A\s*[+-]?nan\s*\z/is 6 14 20
32 14 0;
33 }
34  
35 19 ▶sub isinf($) {
Subroutine isinf: called CC=3 SCAR=11.0
Pod documented
36 19 local $_ = shift;
37 19 ▶ return 0 unless defined;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_ 1 18 19
38 18 ▶ return 1 if /\A\s*[+-]?inf(?:inity)?\s*\z/is;
Branch: 1 branch
BranchTrueFalseTotal
if /\A\s*[+-]?inf(?:inity)?\s*\z/is 6 12 18
39 12 0;
40 }
41  
42 6 ▶sub isneg($) {
Subroutine isneg: called CC=3 SCAR=11.0
Pod documented
43 6 local $_ = shift;
44 6 ▶ return 0 unless defined;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_ 1 5 6
45 5 ▶ return 1 if /\A\s*-/;
Branch: 1 branch
BranchTrueFalseTotal
if /\A\s*-/ 3 2 5
46 2 0;
47 }
48  
49 14 ▶sub isnum($) {
Subroutine isnum: called CC=4 SCAR=13.9
Pod documented
50 14 local $_ = shift;
51 14 ▶ return 0 unless defined;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_ 1 13 14
52 13 ▶ return 1 if isint($_);
Branch: 1 branch
BranchTrueFalseTotal
if isint($_) 4 9 13
53 9 ▶ return 1 if isfloat($_);
Branch: 1 branch
BranchTrueFalseTotal
if &isfloat($_) 5 4 9
54 4 0;
55 }
56  
57 29 ▶sub isfloat($) {
Subroutine isfloat: called CC=8 SCAR=20.8
Pod documented
58 29 local $_ = shift;
59 29 ▶ return 0 unless defined;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_ 1 28 29
60 28 ▶ return 1 if /\A\s*[+-]?
Branch: 1 branch
BranchTrueFalseTotal
if /\A\s*[+-]? (?: (?:0|[1-9][0-9]*)(\.[0-9]+)? | (\.[0-9]+) ) ([eE][+-]?[0-9]+)?\s*\z/sx and $1 or $2 or $3 13 15 28
Condition88%8/9
/\A\s*[+-]? (?: (?:0|[1-9][0-9]*)(\.[0-9]+)? | (\.[0-9]+) ) ([eE][+-]?[0-9]+)?\s*\z/sx and $1 or $2 or $3
l!l&&r!l&&!r
13015
/\A\s*[+-]? (?: (?:0|[1-9][0-9]*)(\.[0-9]+)? | (\.[0-9]+) ) ([eE][+-]?[0-9]+)?\s*\z/sx and $1 or $2
l!l&&r!l&&!r
8515
/\A\s*[+-]? (?: (?:0|[1-9][0-9]*)(\.[0-9]+)? | (\.[0-9]+) ) ([eE][+-]?[0-9]+)?\s*\z/sx and $1
!ll&&!rl&&r
1198
MC/DC75%3/4
/\A\s*[+-]? (?: (?:0|[1-9][0-9]*)(\.[0-9]+)? | (\.[0-9]+) ) ([eE][+-]?[0-9]+)?\s*\z/sx and $1 or $2 or $3
/\A\s*[+-]? (?: (?:0|[1-9][0-9]*)(\.[0-9]+)? | (\.[0-9]+) ) ([eE][+-]?[0-9]+)?\s*\z/sx $1 $2 $3
Truth table57%4/7
A and B or C or D
A= /\A\s*[+-]? (?: (?:0|[1-9][0-9]*)(\.[0-9]+)? | (\.[0-9]+) ) ([eE][+-]?[0-9]+)?\s*\z/sxB= $1C= $2D= $3
ABCDresult
11XX1
0X1X1
101X1
0X011
10011
0X000
10000
61 (?: (?:0|[1-9][0-9]*)(\.[0-9]+)? | (\.[0-9]+) )
62 ([eE][+-]?[0-9]+)?\s*\z/sx && $1 || $2 || $3;
63 15 ▶ return 1 if isnan($_) || isinf($_);
Branch: 1 branch
BranchTrueFalseTotal
if &isnan($_) or &isinf($_) 4 11 15
Condition100%3/3
&isnan($_) or &isinf($_)
l!l&&r!l&&!r
2211
MC/DC100%2/2
&isnan($_) or &isinf($_)
&isnan($_) &isinf($_)
Truth table100%3/3
A or B
A= &isnan($_)B= &isinf($_)
ABresult
1X1
011
000
64 11 0;
65 }
66  
67 2 1;
68 # ABSTRACT: Pure-perl drop-in replacement/approximation of Scalar::Util::Numeric
69  
70 __END__
↑ Summary