| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 21 | ▶ | return 1 if /\A\s*[+-]?(?:0|[1-9][0-9]*)\s*\z/s; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 20 | ▶ | return 1 if /\A\s*[+-]?nan\s*\z/is; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 18 | ▶ | return 1 if /\A\s*[+-]?inf(?:inity)?\s*\z/is; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 5 | ▶ | return 1 if /\A\s*-/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 13 | ▶ | return 1 if isint($_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 9 | ▶ | return 1 if isfloat($_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 28 | ▶ | return 1 if /\A\s*[+-]? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
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
/\A\s*[+-]?
(?: (?:0|[1-9][0-9]*)(\.[0-9]+)? | (\.[0-9]+) )
([eE][+-]?[0-9]+)?\s*\z/sx and $1 or $2
/\A\s*[+-]?
(?: (?:0|[1-9][0-9]*)(\.[0-9]+)? | (\.[0-9]+) )
([eE][+-]?[0-9]+)?\s*\z/sx and $1
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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
Condition100%3/3
&isnan($_) or &isinf($_)
MC/DC100%2/2
&isnan($_) or &isinf($_)
&isnan($_)
&isinf($_)
Truth table100%3/3
A or B
A= &isnan($_)B= &isinf($_)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 11 | 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | # ABSTRACT: Pure-perl drop-in replacement/approximation of Scalar::Util::Numeric | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||