blib/lib/Test2/Compare/Ref.pm

filter: Statementstmt 100% 40 / 40 Branchbran 100% 12 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 11 / 11 Podpod 75.0% 3 / 4 totaltotal 98.5% 66 / 67 CC 7 SCAR 9.3
CC
7
Cov
100%
verify
5.0
init
3.0
BEGIN
1.0
CRAP 2.5
« blib/lib/Test2/Event/Generic.pm ↑ Summary blib/lib/Test2/Tools/Warnings.pm »
1 package Test2::Compare::Ref;
2 176 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 176 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 176 ▶use base 'Test2::Compare::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 176 our $VERSION = '1.302226';
8  
9 176 ▶use Test2::Util::HashBase qw/input/;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 176 ▶use Test2::Util::Ref qw/render_ref rtype/;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 176 ▶use Scalar::Util qw/refaddr/;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 176 ▶use Carp qw/croak/;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 65 ▶sub init {
Subroutine init: called CC=3 SCAR=11.0
Pod undocumented
16 65 my $self = shift;
17  
18 croak "'input' is a required attribute"
19 65 ▶ unless $self->{+INPUT};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"input"} 1 64 65
20  
21 croak "'input' must be a reference, got '" . $self->{+INPUT} . "'"
22 64 ▶ unless ref $self->{+INPUT};
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self->{"input"} 1 63 64
23  
24 63 $self->SUPER::init();
25 }
26  
27 4 ▶sub operator { '==' }
Subroutine operator: called CC=1 SCAR=0.0
Pod documented
28  
29 4 ▶sub name { render_ref($_[0]->{+INPUT}) }
Subroutine name: called CC=1 SCAR=0.0
Pod documented
30  
31 68 ▶sub verify {
Subroutine verify: called CC=5 SCAR=16.1
Pod documented
32 68 my $self = shift;
33 68 my %params = @_;
34 68 my ($got, $exists) = @params{qw/got exists/};
35  
36 68 ▶ return 0 unless $exists;
Branch: 1 branch
BranchTrueFalseTotal
unless $exists 1 67 68
37  
38 67 my $in = $self->{+INPUT};
39 67 ▶ return 0 unless ref $in;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $in 1 66 67
40 66 ▶ return 0 unless ref $got;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $got 2 64 66
41  
42 64 my $in_type = rtype($in);
43 64 my $got_type = rtype($got);
44  
45 64 ▶ return 0 unless $in_type eq $got_type;
Branch: 1 branch
BranchTrueFalseTotal
unless $in_type eq $got_type 1 63 64
46  
47 # Don't let overloading mess with us.
48 63 return refaddr($in) == refaddr($got);
49 }
50  
51 176 1;
52  
53 __END__
« blib/lib/Test2/Event/Generic.pm ↑ Summary blib/lib/Test2/Tools/Warnings.pm »