blib/lib/Class/Privacy.pm

filter: Statementstmt 83.3% 20 / 24 Branchbran 50.0% 2 / 4 Conditioncond 50.0% 3 / 6 MC/DCmcdc 50.0% 2 / 4 Subroutinesub 80.0% 4 / 5 Podpod n/a totaltotal 72.0% 31 / 43 CC 5 SCAR 10.1
CC
5
Cov
74%
P
3.6
main
3.6
BEGIN
1.1
CRAP 2.8
↑ Summary
1 package Class::Privacy;
2  
3 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 require 5.006001; # Overloading %{} et alia doesn't work before this.
6  
7 1 our $VERSION = 0.03;
8  
9 5 ▶sub import {
Subroutine import: called CC=1 SCAR=0.5
10 5 my $class = shift;
11 5 my ($caller, $file) = (caller(0))[0,1];
12 5 my $check = "Class::Privacy::check::$caller";
13 0 ▶ eval <<__EOF__;
Subroutine BEGIN: called CC=1 SCAR=0.7
Subroutine main: not called CC=3 SCAR=12.9
Subroutine P: called CC=3 SCAR=12.9
Branch: 2 branches
BranchTrueFalseTotal
if ($caller eq 'main' and $file eq 't/00use.t') { } 0 0 0
if ($caller eq 'P' and $file eq 't/P.pm') { } 4 3 7
Condition50%3/6
$caller eq "main" and $file eq "t/00use.t"
!ll&&!rl&&r
000
$caller eq "P" and $file eq "t/P.pm"
!ll&&!rl&&r
214
MC/DC0%0/2
$caller eq "main" and $file eq "t/00use.t"
$caller eq "main" $file eq "t/00use.t"
MC/DC100%2/2
$caller eq "P" and $file eq "t/P.pm"
$caller eq "P" $file eq "t/P.pm"
Truth table0%0/3
A and B
A= $caller eq "main"B= $file eq "t/00use.t"
ABresult
0X0
100
111
Truth table100%3/3
A and B
A= $caller eq "P"B= $file eq "t/P.pm"
ABresult
0X0
100
111
14 sub $check {
15 my (\$caller, \$file, \$line) = (caller(0))[0,1,2];
16 if (\$caller eq "$caller" && \$file eq "$file") {
17 return \$_[0];
18 } else {
19 # Tried to use Carp::croak here but that lead into strange
20 # error where Carp::Heavy tried to stringify the object for
21 # no apparent good reason. Anyway, using die() directly
22 # is here much simpler and faster.
23 die("Cannot dereference '$caller' object at \$file line \$line.\n");
24 }
25 }
26 package $caller;
27 use overload
28 '\%{}' => \\&$check,
29 '\@{}' => \\&$check,
30 '\${}' => \\&$check,
31 '\&{}' => \\&$check; # Unlikely, but while we are at it...
32 __EOF__
33 }
34  
35 1 1;
36 __END__
↑ Summary