| 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; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | class Getopt::Pad::Type::Number :isa(Getopt::Pad::Type) :abstract { | ||||||||||||||||||||||||||||||||||||||||||
| 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 SPEC_KEYS => ['min', 'max']; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | field $min :param :reader = undef; | ||||||||||||||||||||||||||||||||||||||||||
| 14 | 0 | ▶ | field $max :param :reader = undef; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
min: not called CC=1 SCAR=2.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | # A bound that is not a number, or an empty range, is a spec mistake. | ||||||||||||||||||||||||||||||||||||||||||
| 17 | 0 | ▶ | method checkSpecKeys :common (%args) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
checkSpecKeys: called CC=6 SCAR=18.1
Subroutine
max: not called CC=1 SCAR=0.2
Pod
documented
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 128 | foreach my $bound (grep { defined $args{$_} } qw(min max)) { | |||||||||||||||||||||||||||||||||||||||||
| 19 | 41 | ▶ | return sprintf("%s must be a number, not '%s'", $bound, $args{$bound}) if !looks_like_number($args{$bound}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||||||||||||||||
| 21 | 127 | ▶ | return sprintf("min %s is larger than max %s", $args{min}, $args{max}) if defined $args{min} && defined $args{max} && $args{min} > $args{max}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
defined $args{"min"} and defined $args{"max"} and $args{"min"} > $args{"max"}
defined $args{"min"} and defined $args{"max"}
MC/DC66%2/3
defined $args{"min"} and defined $args{"max"} and $args{"min"} > $args{"max"}
defined $args{"min"}
defined $args{"max"}
$args{"min"} > $args{"max"}
Truth table75%3/4
A and B and C
A= defined $args{"min"}B= defined $args{"max"}C= $args{"min"} > $args{"max"}
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 126 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 23 | 23 | } | |||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | 158 | ▶ | method glSuffix() { return '=s' } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
glSuffix: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | 23 | method checkFormat($value); | |||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | 3 | ▶ | method coerce($value) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
coerce: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | 3 | return $value + 0; | |||||||||||||||||||||||||||||||||||||||||
| 31 | 23 | } | |||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | # The bounds are compared as converted, so a subclass whose numbers are | ||||||||||||||||||||||||||||||||||||||||||
| 34 | # objects (a Math::BigInt) compares them exactly. | ||||||||||||||||||||||||||||||||||||||||||
| 35 | 64 | ▶ | method check($value) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | 64 | my $problem = $self->checkFormat($value); | |||||||||||||||||||||||||||||||||||||||||
| 37 | 64 | ▶ | return $problem if defined $problem; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | 43 | my $number = $self->coerce($value); | |||||||||||||||||||||||||||||||||||||||||
| 40 | 43 | ▶ | return sprintf('%s is smaller than the minimum of %s', $value, $min) if defined $min && $number < $self->coerce($min); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $min and $number < $self->coerce($min)
MC/DC100%2/2
defined $min and $number < $self->coerce($min)
defined $min
$number < $self->coerce($min)
Truth table100%3/3
A and B
A= defined $minB= $number < $self->coerce($min)
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | 40 | ▶ | return sprintf('%s is larger than the maximum of %s', $value, $max) if defined $max && $number > $self->coerce($max); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $max and $number > $self->coerce($max)
MC/DC100%2/2
defined $max and $number > $self->coerce($max)
defined $max
$number > $self->coerce($max)
Truth table100%3/3
A and B
A= defined $maxB= $number > $self->coerce($max)
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | 39 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 43 | 23 | } | |||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | 23 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | __END__ | ||||||||||||||||||||||||||||||||||||||||||