Out/ParamConstraints.pm

filter: Statementstmt 89.6% 26 / 29 Branchbran 33.3% 2 / 6 Conditioncond 33.3% 5 / 15 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 90.0% 9 / 10 Podpod 0.0% 0 / 2 totaltotal 60.0% 42 / 70 CC 9 SCAR 14.2
CC
9
Cov
66%
assert_NonNegativeNumber
8.9
_croakf
6.0
_is_CodeRef
2.3
CRAP 4.1
↑ Summary Out.pm »
1 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 8 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 package Time::Out::ParamConstraints;
5  
6 # keeping the following $VERSION declaration on a single line is important
7 #<<<
8 8 ▶use version 0.9915; our $VERSION = version->declare( '1.0.0' );
Subroutine BEGIN: called CC=1 SCAR=0.0
9 #>>>
10  
11 8 ▶use Exporter qw( import );
Subroutine BEGIN: called CC=1 SCAR=0.0
12 8 ▶use Scalar::Util qw( blessed looks_like_number reftype );
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 8 our @EXPORT_OK = qw( assert_NonNegativeNumber assert_CodeRef );
15  
16 sub _is_CodeRef ( $ );
17 sub _is_String ( $ );
18 sub _croakf ( $@ );
19  
20 20 ▶sub assert_NonNegativeNumber( $ ) {
Subroutine assert_NonNegativeNumber: called CC=5 SCAR=21.9
Pod undocumented
21 20 my ( $value ) = @_;
22  
23 20 ▶ _is_String $value
Branch: 1 branch
BranchTrueFalseTotal
&_is_String($value) && &looks_like_number($value) && !($value =~ /\A (?: Inf (?: inity )? | NaN ) \z/xi) && $value >= 0 ? : 20 0 20
Condition33%3/9
&_is_String($value) and &looks_like_number($value) and not $value =~ /\A (?: Inf (?: inity )? | NaN ) \z/xi and $value >= 0
!ll&&!rl&&r
0020
&_is_String($value) and &looks_like_number($value) and not $value =~ /\A (?: Inf (?: inity )? | NaN ) \z/xi
!ll&&!rl&&r
0020
&_is_String($value) and &looks_like_number($value)
!ll&&!rl&&r
0020
MC/DC0%0/4
&_is_String($value) and &looks_like_number($value) and not $value =~ /\A (?: Inf (?: inity )? | NaN ) \z/xi and $value >= 0
&_is_String($value) &looks_like_number($value) not $value =~ /\A (?: Inf (?: inity )? | NaN ) \z/xi $value >= 0
Truth table20%1/5
A and B and not(C) and D
A= &_is_String($value)B= &looks_like_number($value)C= not $value =~ /\A (?: Inf (?: inity )? | NaN ) \z/xiD= $value >= 0
ABCDresult
0XXX0
10XX0
110X0
11100
11111
24 && looks_like_number $value
25 && $value !~ /\A (?: Inf (?: inity )? | NaN ) \z/xi
26 && $value >= 0 ? return $value : _croakf 'value is not a non-negative number';
27 }
28  
29 20 ▶sub assert_CodeRef( $ ) {
Subroutine assert_CodeRef: called CC=2 SCAR=7.2
Pod undocumented
30 20 my ( $value ) = @_;
31  
32 20 ▶ _is_CodeRef $value ? return $value : _croakf 'value is not a code reference';
Branch: 1 branch
BranchTrueFalseTotal
&_is_CodeRef($value) ? : 20 0 20
33 }
34  
35 20 ▶sub _is_CodeRef( $ ) {
Subroutine _is_CodeRef: called CC=2 SCAR=8.1
36 20 my ( $value ) = @_;
37  
38 20 ▶ return !defined blessed $value && ref $value eq 'CODE';
Condition33%1/3
!defined(builtin::blessed($value)) && ref $value eq 'CODE'
!ll&&!rl&&r
0020
MC/DC0%0/2
!defined(builtin::blessed($value)) && ref $value eq 'CODE'
!defined(builtin::blessed($value)) ref $value eq 'CODE'
Truth table33%1/3
not(A) && B
A= !defined(builtin::blessed($value))B= ref $value eq 'CODE'
ABresult
0X0
100
111
39 }
40  
41 20 ▶sub _is_String( $ ) {
Subroutine _is_String: called CC=2 SCAR=8.1
42 20 my ( $value ) = @_;
43  
44 20 ▶ return defined $value && reftype \$value eq 'SCALAR';
Condition33%1/3
defined $value && builtin::reftype(\$value) eq 'SCALAR'
!ll&&!rl&&r
0020
MC/DC0%0/2
defined $value && builtin::reftype(\$value) eq 'SCALAR'
defined $value builtin::reftype(\$value) eq 'SCALAR'
Truth table33%1/3
A && B
A= defined $valueB= builtin::reftype(\$value) eq 'SCALAR'
ABresult
0X0
100
111
45 }
46  
47 0 ▶sub _croakf( $@ ) {
Subroutine _croakf: not called CC=2 SCAR=17.9
48 # load Carp lazily
49 0 require Carp;
50 0 ▶ @_ = ( ( @_ == 1 ? shift : sprintf shift, @_ ) . ', stopped' );
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 ? : 0 0 0
51 0 goto &Carp::croak;
52 }
53  
54 8 1;
↑ Summary Out.pm »