blib/lib/Devel/Probe.pm

filter: Statementstmt 98.0% 51 / 52 Branchbran 75.0% 12 / 16 Conditioncond 85.7% 6 / 7 MC/DCmcdc 50.0% 2 / 4 Subroutinesub 100% 10 / 10 Podpod 100% 3 / 3 totaltotal 91.3% 84 / 92 CC 14 SCAR 18.5
CC
14
Cov
92%
config
11.1
add_probe
4.2
BEGIN
1.0
CRAP 6.4
↑ Summary probe.xs »
1 package Devel::Probe;
2 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 8 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 8 ▶use Storable qw(dclone);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 8 ▶use XSLoader;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 8 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 8 our $VERSION = '0.000006';
10 8 XSLoader::load( 'Devel::Probe', $VERSION );
11  
12 8 ▶sub import {
Subroutine import: called CC=1 SCAR=0.0
13 8 my ($class) = @_;
14 8 Devel::Probe::install();
15 }
16  
17 8 ▶use constant {
Subroutine BEGIN: called CC=1 SCAR=0.0
18 8 NONE => 0,
19 ONCE => 1,
20 PERMANENT => 2,
21 8 };
22  
23 5 ▶sub config {
Subroutine config: called CC=11 SCAR=24.0
Pod documented
24 5 my ($config) = @_;
25  
26 5 Devel::Probe::disable();
27 5 ▶ return unless $config;
Branch: 1 branch
BranchTrueFalseTotal
unless $config 0 5 5
28  
29 5 foreach my $action (@{ $config->{actions} }) {
30 21 ▶ if ($action->{action} eq 'enable') {
Branch: 1 branch
BranchTrueFalseTotal
if ($action->{"action"} eq "enable") 4 17 21
31 4 Devel::Probe::enable();
32 4 next;
33 }
34 17 ▶ if ($action->{action} eq 'disable') {
Branch: 1 branch
BranchTrueFalseTotal
if ($action->{"action"} eq "disable") 1 16 17
35 1 Devel::Probe::disable();
36 1 next;
37 }
38 16 ▶ if ($action->{action} eq 'clear') {
Branch: 1 branch
BranchTrueFalseTotal
if ($action->{"action"} eq "clear") 1 15 16
39 1 Devel::Probe::clear();
40 1 next;
41 }
42 15 ▶ if ($action->{action} eq 'define') {
Branch: 1 branch
BranchTrueFalseTotal
if ($action->{"action"} eq "define") 15 0 15
43 15 my $file = $action->{file};
44 15 ▶ next unless $file;
Branch: 1 branch
BranchTrueFalseTotal
unless $file 0 15 15
45  
46 15 ▶ my $type = $action->{type} // ONCE;
Condition100%2/2
$action->{"type"} // 1
l!l
312
MC/DC100%1/1
$action->{"type"} // 1
$action->{"type"}
Truth table100%2/2
A
A= $action->{"type"}
Aresult
11
00
47 15 my $argument = $action->{argument};
48 15 ▶ foreach my $line (@{ $action->{lines} // [] }) {
Condition100%2/2
$action->{"lines"} // []
l!l
132
MC/DC100%1/1
$action->{"lines"} // []
$action->{"lines"}
Truth table100%2/2
A
A= $action->{"lines"}
Aresult
11
00
49 21 add_probe($file, $line, $type, $argument);
50 }
51 15 next;
52 }
53 }
54 }
55  
56 21021 ▶sub add_probe {
Subroutine add_probe: called CC=4 SCAR=14.5
Pod documented
57 21021 my ($file, $line, $type, $argument) = @_;
58 21021 ▶ if ($type ne ONCE && $type ne PERMANENT) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type ne 1 and $type ne 2) 0 21021 21021
Condition66%2/3
$type ne 1 and $type ne 2
!ll&&!rl&&r
2001710040
MC/DC0%0/2
$type ne 1 and $type ne 2
$type ne 1 $type ne 2
Truth table66%2/3
A and B
A= $type ne 1B= $type ne 2
ABresult
0X0
100
111
59 0 croak sprintf("'%s' is not a valid probe type: try Devel::Probe::ONCE|PERMANENT", $type);
60 }
61  
62 21021 my $probes = Devel::Probe::_internal_probe_state();
63 21021 ▶ $probes->{$file}->{$line} = [$type, defined $argument ? $argument : ()];
Branch: 1 branch
BranchTrueFalseTotal
defined $argument ? : 11004 10017 21021
64 }
65  
66 1 ▶sub dump {
Subroutine dump: called CC=1 SCAR=0.0
Pod documented
67 1 return dclone(Devel::Probe::_internal_probe_state());
68 }
69  
70 8 1;
71 __END__
↑ Summary probe.xs »