blib/lib/Tie/BoundedInteger.pm

filter: Statementstmt 38.1% 8 / 21 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 40.0% 2 / 5 Podpod n/a totaltotal 30.3% 10 / 33 CC 3 SCAR 17.9
CC
3
Cov
31%
STORE
12.0
TIESCALAR
2.0
FETCH
2.0
CRAP 6.0
↑ Summary
1 package Tie::BoundedInteger;
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 2 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 our $VERSION = '1.075';
7  
8 0 ▶sub TIESCALAR {
Subroutine TIESCALAR: not called CC=1 SCAR=6.9
9 0 my $class = shift;
10 0 my $value = shift;
11 0 my $max = shift;
12  
13 0 my $self = bless [ 0, $max ], $class;
14  
15 0 $self->STORE( $value );
16  
17 0 return $self;
18 }
19  
20 0 ▶sub FETCH { $_[0]->[0] }
Subroutine FETCH: not called CC=1 SCAR=6.9
21  
22 0 ▶sub STORE {
Subroutine STORE: not called CC=3 SCAR=24.8
23 0 my $self = shift;
24 0 my $value = shift;
25  
26 0 my $magnitude = abs $value;
27  
28 0 ▶ croak( "The [$value] exceeds the allowed limit [$self->[1]]" )
Branch: 1 branch
BranchTrueFalseTotal
if int $value != $value or $magnitude > $self->[1] 0 0 0
Condition0%0/3
int $value != $value or $magnitude > $self->[1]
l!l&&r!l&&!r
000
MC/DC0%0/2
int $value != $value or $magnitude > $self->[1]
int $value != $value $magnitude > $self->[1]
Truth table0%0/3
A or B
A= int $value != $valueB= $magnitude > $self->[1]
ABresult
1X1
011
000
29 if( int($value) != $value || $magnitude > $self->[1] );
30  
31 0 $self->[0] = $value;
32  
33 0 $value;
34 }
35  
36 2 1;
37  
38 __END__
↑ Summary