blib/lib/Hash/Spy.pm

filter: Statementstmt 100% 29 / 29 Branchbran 83.3% 5 / 6 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 5 / 5 Podpod 100% 1 / 1 totaltotal 93.1% 41 / 44 CC 5 SCAR 11.8
CC
5
Cov
95%
spy_hash
5.0
BEGIN
1.0
BEGIN
1.0
CRAP 3.2
↑ Summary Spy.xs »
1 package Hash::Spy;
2  
3 1 our $VERSION = '0.01';
4  
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 require Exporter;
11 1 our @ISA = qw(Exporter);
12 1 our @EXPORT_OK = qw(spy_hash);
13  
14 1 require XSLoader;
15 1 XSLoader::load('Hash::Spy', $VERSION);
16  
17 1 my %cb_slot = ( delete => 0,
18 store => 1,
19 clear => 2,
20 empty => 3 );
21  
22 6 ▶sub spy_hash (\%@) {
Subroutine spy_hash: called CC=5 SCAR=16.2
Pod documented
23 6 my $hash = shift;
24 6 my $spy = _hash_get_spy($hash);
25 6 ▶ while (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 7 6 13
26 7 my $name = shift;
27 7 ▶ my $slot = $cb_slot{$name} //
Condition50%1/2
$cb_slot{$name} // croak("bad spy callback '${name}'")
l!l
70
MC/DC0%0/1
$cb_slot{$name} // croak("bad spy callback '${name}'")
$cb_slot{$name}
Truth table50%1/2
A
A= $cb_slot{$name}
Aresult
11
00
28 croak "bad spy callback '$name'";
29 7 my $cb = shift;
30 7 ▶ if (defined $cb) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $cb) 6 1 7
31 6 ▶ UNIVERSAL::isa($cb, 'CODE')
Branch: 1 branch
BranchTrueFalseTotal
UNIVERSAL::isa($cb, "CODE") or croak("spy callback '${name}' is not a CODE ref") 6 0 6
32 or croak "spy callback '$name' is not a CODE ref";
33 }
34 7 $spy->_set_cb($slot, $cb);
35 }
36 6 1;
37 }
38  
39 1 1;
40 __END__
↑ Summary Spy.xs »