blib/lib/Scalar/LockRefType.pm

filter: Statementstmt 100% 20 / 20 Branchbran 100% 8 / 8 Conditioncond 60.0% 3 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 100% 7 / 7 Podpod n/a totaltotal 88.3% 38 / 43 CC 7 SCAR 10.5
CC
7
Cov
94%
STORE
4.1
TIESCALAR
4.0
BEGIN
1.0
CRAP 2.9
↑ Summary
1 package Scalar::LockRefType;
2  
3 1 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 our $VERSION = '0.03';
9  
10 9 ▶sub TIESCALAR {
Subroutine TIESCALAR: called CC=4 SCAR=13.9
11 9 my ($class, $type) = @_;
12 9 ▶ return bless {
Branch: 3 branches
BranchTrueFalseTotal
@_ < 2 ? : 1 8 9
ref $type ? : 3 5 8
length $type ? : 3 2 5
13 value => undef,
14 type => @_ < 2 ? undef
15 : ref($type) ? ref($type)
16 : length($type) ? $type
17 : ''
18 };
19 }
20  
21 9 ▶sub FETCH { return $_[0]->{value} }
Subroutine FETCH: called CC=1 SCAR=0.0
22  
23 8 ▶sub STORE {
Subroutine STORE: called CC=4 SCAR=14.0
24 8 my ($self, $value) = @_;
25 8 ▶ my $ref = ref $value // '';
Condition50%1/2
ref $value // ""
l!l
80
MC/DC0%0/1
ref $value // ""
ref $value
Truth table50%1/2
A
A= ref $value
Aresult
11
00
26 8 ▶ $self->{type} //= $ref;
Condition66%2/3
$self->{"type"} //= $ref
l!l&&r!l&&!r
710
MC/DC0%0/2
$self->{"type"} //= $ref
$self->{"type"} $ref
Truth table66%2/3
A //= B
A= $self->{"type"}B= $ref
ABresult
1X1
011
000
27 8 ▶ croak 'invalid reference type' if $ref ne $self->{type};
Branch: 1 branch
BranchTrueFalseTotal
if $ref ne $self->{"type"} 3 5 8
28 5 return $self->{value} = $value;
29 }
30  
31 __END__
↑ Summary