| 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
Condition50%3/6
$caller eq "main" and $file eq "t/00use.t"
$caller eq "P" and $file eq "t/P.pm"
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"
Truth table100%3/3
A and B
A= $caller eq "P"B= $file eq "t/P.pm"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||||||||||||||||||||||||