Pad/Type/Float.pm

filter: Statementstmt 100% 26 / 26 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 100% 37 / 37 CC 3 SCAR 5.6
CC
3
Cov
100%
checkFormat
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.8
« Pad/Spec/Level.pm ↑ Summary Pad/Type/File.pm »
1 23 ▶use v5.26;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 23 ▶use Object::Pad;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 23 ▶use Getopt::Pad::Type::Number;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 class Getopt::Pad::Type::Float :isa(Getopt::Pad::Type::Number) :strict(params) {
7 23 ▶ use Scalar::Util qw(looks_like_number);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 23 our $VERSION = '0.06';
10  
11 23 ▶ use constant NAMES => ['f', 'float', 'num', 'number'];
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 6 ▶ method checkFormat($value) {
Subroutine checkFormat: called CC=3 SCAR=11.0
Pod documented
14 6 ▶ return sprintf("'%s' is not a number", $value) if !looks_like_number($value);
Branch: 1 branch
BranchTrueFalseTotal
unless &looks_like_number($value) 1 5 6
15  
16 # Catches inf and nan however they are spelled, and values too large
17 # for a Perl number (1e999): times 0, an infinity becomes nan, and
18 # nan equals nothing.
19 5 my $number = $value + 0;
20 5 ▶ return sprintf("'%s' is not a finite number", $value) if $number * 0 != 0;
Branch: 1 branch
BranchTrueFalseTotal
if $number * 0 != 0 3 2 5
21 2 return undef;
22 23 }
23 }
24  
25 23 1;
26  
27 __END__
« Pad/Spec/Level.pm ↑ Summary Pad/Type/File.pm »