Monitor/Hash.pm

filter: Statementstmt 42.0% 21 / 50 Branchbran 20.0% 2 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 28.5% 4 / 14 Podpod 0.0% 0 / 1 totaltotal 36.0% 27 / 75 CC 6 SCAR 17.6
CC
6
Cov
38%
DESTROY
20.0
TIEHASH
3.1
unmonitor
2.0
CRAP 5.8
« Monitor/Array.pm ↑ Summary Monitor/Scalar.pm »
1 package Devel::Monitor::Hash;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4
5 1 ▶use Devel::Monitor::Common qw(:all);
Subroutine BEGIN: called CC=1 SCAR=0.0
6
7 1 our $id = 0;
8
9 2 ▶sub TIEHASH {
Subroutine TIEHASH: called CC=3 SCAR=11.4
10 2 my ($class, $varRef, $id, $isCode) = @_;
11 2 my $self = {};
12 2 bless($self => $class);
13 2 $self->{Devel::Monitor::Common::F_VAR()} = {%$varRef};
14 2 ▶ if ($id) {
Branch: 1 branch
BranchTrueFalseTotal
if ($id) { } 2 0 2
15 2 $self->{Devel::Monitor::Common::F_ID()} = $id;
16 } else {
17 0 $self->{Devel::Monitor::Common::F_ID()} = 'hash_'.++$id;
18 }
19 2 $self->{Devel::Monitor::Common::F_IS_CODE()} = $isCode;
20 2 ▶ if ($isCode) {
Branch: 1 branch
BranchTrueFalseTotal
if ($isCode) { } 0 2 2
21 0 Devel::Monitor::Common::printMsg("MONITOR CODE HASH : ".$self->{Devel::Monitor::Common::F_ID()}."\n");
22 } else {
23 2 Devel::Monitor::Common::printMsg("MONITOR HASH : ".$self->{Devel::Monitor::Common::F_ID()}."\n");
24 }
25 2 return $self;
26 }
27
28 0 ▶sub DESTROY {
Subroutine DESTROY: not called CC=4 SCAR=30.0
29 0 my $self = shift;
30 0 ▶ if ($self->{Devel::Monitor::Common::F_IS_CODE()}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'_isCode'}) { } 0 0 0
31 0 ▶ Devel::Monitor::Common::printMsg("DESTROY CODE HASH : ".$self->{Devel::Monitor::Common::F_ID()}."\n") unless $self->{Devel::Monitor::Common::F_UNMONITORED()};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_unmonitored"} 0 0 0
32 } else {
33 0 ▶ Devel::Monitor::Common::printMsg("DESTROY HASH : ".$self->{Devel::Monitor::Common::F_ID()}."\n") unless $self->{Devel::Monitor::Common::F_UNMONITORED()};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_unmonitored"} 0 0 0
34 }
35 }
36
37 0 ▶sub unmonitor {
Subroutine unmonitor: not called CC=1 SCAR=6.9
Pod undocumented
38 0 my ($varRef) = @_;
39 0 my $hashRef;
40 {
41 0 my $self = tied %$varRef;
42 0 $hashRef = $self->{Devel::Monitor::Common::F_VAR()};
43 0 $self->{Devel::Monitor::Common::F_UNMONITORED()} = 1;
44 0 Devel::Monitor::Common::printMsg("UNMONITOR HASH : ".$self->{Devel::Monitor::Common::F_ID()}."\n");
45 }
46 0 untie %$varRef;
47 0 %$varRef = %$hashRef;
48 }
49
50 #Copy/Pasted from Tie::Hash.pm
51 #Added "->{Devel::Monitor::Common::F_VAR()}"
52 0 ▶sub STORE { $_[0]->{Devel::Monitor::Common::F_VAR()}->{$_[1]} = $_[2] }
Subroutine STORE: not called CC=1 SCAR=6.9
53 0 ▶sub FETCH { $_[0]->{Devel::Monitor::Common::F_VAR()}->{$_[1]} }
Subroutine FETCH: not called CC=1 SCAR=6.9
54 0 ▶sub FIRSTKEY { my $a = scalar keys %{$_[0]->{Devel::Monitor::Common::F_VAR()}}; each %{$_[0]->{Devel::Monitor::Common::F_VAR()}} }
Subroutine FIRSTKEY: not called CC=1 SCAR=6.9
55 0 ▶sub NEXTKEY { each %{$_[0]->{Devel::Monitor::Common::F_VAR()}} }
Subroutine NEXTKEY: not called CC=1 SCAR=6.9
56 0 ▶sub EXISTS { exists $_[0]->{Devel::Monitor::Common::F_VAR()}->{$_[1]} }
Subroutine EXISTS: not called CC=1 SCAR=6.9
57 0 ▶sub DELETE { delete $_[0]->{Devel::Monitor::Common::F_VAR()}->{$_[1]} }
Subroutine DELETE: not called CC=1 SCAR=6.9
58 0 ▶sub CLEAR { %{$_[0]->{Devel::Monitor::Common::F_VAR()}} = () }
Subroutine CLEAR: not called CC=1 SCAR=6.9
59 0 ▶sub SCALAR { scalar %{$_[0]->{Devel::Monitor::Common::F_VAR()}} }
Subroutine SCALAR: not called CC=1 SCAR=6.9
60
61 1 1;
« Monitor/Array.pm ↑ Summary Monitor/Scalar.pm »