Mock/Quick/Object.pm

filter: Statementstmt 95.3% 62 / 65 Branchbran 83.3% 5 / 6 Conditioncond 66.6% 4 / 6 MC/DCmcdc 50.0% 2 / 4 Subroutinesub 84.2% 16 / 19 Podpod 0.0% 0 / 3 totaltotal 86.4% 89 / 103 CC 6 SCAR 5.9
CC
6
Cov
92%
__ANON__
4.0
AUTOLOAD
3.0
DOES
2.0
CRAP 1.8
« Mock/Quick/Method.pm ↑ Summary Mock/Quick/Object/Control.pm »
1 package Mock::Quick::Object;
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 Mock::Quick::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 8 ▶use Mock::Quick::Object::Control;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 8 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 8 ▶use Scalar::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 8 our $AUTOLOAD;
11  
12 13 ▶class_meth new => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
13 13 my $class = shift;
14 13 my %proto = @_;
15 13 return bless \%proto, $class;
16 8 };
17  
18 9 ▶sub AUTOLOAD {
Subroutine AUTOLOAD: called CC=3 SCAR=11.0
19 # Do not shift this, we need it when we use goto &$sub
20 9 my ($self) = @_;
21 9 my ( $package, $sub ) = ( $AUTOLOAD =~ m/^(.+)::([^:]+)$/ );
22 9 $AUTOLOAD = undef;
23  
24 9 ▶ Carp::croak "Can't locate object method \"$sub\" via package \"$package\""
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($self) 0 9 9
25 unless Scalar::Util::blessed( $self );
26  
27 9 my $code = $self->can( $sub );
28 9 ▶ Carp::croak "Can't locate object method \"$sub\" in this instance"
Branch: 1 branch
BranchTrueFalseTotal
unless $code 1 8 9
29 unless $code;
30  
31 8 goto &$code;
32 };
33  
34 alt_meth can => (
35 0 ▶ class => sub { no warnings 'misc'; goto &UNIVERSAL::can },
Subroutine BEGIN: called CC=1 SCAR=0.2
Subroutine __ANON__: not called CC=1 SCAR=0.2
36 16 ▶ obj => sub {
Subroutine __ANON__: called CC=4 SCAR=13.9
37 16 my ( $self, $name ) = @_;
38  
39 16 my $control = Mock::Quick::Object::Control->new( $self );
40 16 ▶ return if $control->strict && !exists $self->{$name};
Branch: 1 branch
BranchTrueFalseTotal
if $control->strict and not exists $self->{$name} 4 12 16
Condition100%3/3
$control->strict and not exists $self->{$name}
!ll&&!rl&&r
934
MC/DC100%2/2
$control->strict and not exists $self->{$name}
$control->strict not exists $self->{$name}
Truth table100%3/3
A and not(B)
A= $control->strictB= not exists $self->{$name}
ABresult
0X0
100
111
41  
42 12 my $sub;
43 {
44 8 ▶ no warnings 'misc';
Subroutine BEGIN: called CC=1 SCAR=0.0
45 12 $sub = UNIVERSAL::can( $self, $name );
46 }
47 44 ▶ $sub ||= sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
48 44 unshift @_ => ( shift( @_ ), $name );
49 44 goto &call;
50 12 ▶ };
Condition33%1/3
$sub ||= sub { unshift @_, (shift @_, $name); goto \&Mock::Quick::Object::call; }
l!l&&r!l&&!r
0120
MC/DC0%0/2
$sub ||= sub { unshift @_, (shift @_, $name); goto \&Mock::Quick::Object::call; }
$sub sub { unshift @_, (shift @_, $name); goto \&Mock::Quick::Object::call; }
Truth table33%1/3
A ||= B
A= $subB= sub { unshift @_, (shift @_, $name); goto \&Mock::Quick::Object::call; }
ABresult
1X1
011
000
51 12 inject( Scalar::Util::blessed( $self ), $name, $sub );
52 12 return $sub;
53 },
54 8 );
55  
56 # http://perldoc.perl.org/perlobj.html#Default-UNIVERSAL-methods
57 # DOES is equivalent to isa by default
58 8 ▶sub isa { no warnings 'misc'; goto &UNIVERSAL::isa }
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine isa: called CC=1 SCAR=0.0
Pod undocumented
59 0 ▶sub DOES { goto &isa }
Subroutine DOES: not called CC=1 SCAR=6.9
Pod undocumented
60 0 ▶sub VERSION { no warnings 'misc'; goto &UNIVERSAL::VERSION }
Subroutine BEGIN: called CC=1 SCAR=0.2
Subroutine VERSION: not called CC=1 SCAR=0.2
Pod undocumented
61  
62 14 ▶obj_meth DESTROY => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
63 14 my $self = shift;
64 14 Mock::Quick::Object::Control->new( $self )->_clean;
65 14 unshift @_ => ( $self, 'DESTROY' );
66 14 goto &call;
67 8 };
68  
69 8 purge_util();
70  
71 8 1;
72  
73 __END__
« Mock/Quick/Method.pm ↑ Summary Mock/Quick/Object/Control.pm »