| 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
| |||||||||||
| 20 | |||||||||||
| 21 | croak "'input' must be a reference, got '" . $self->{+INPUT} . "'" | ||||||||||
| 22 | 64 | ▶ | unless ref $self->{+INPUT}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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
| |||||||||||
| 37 | |||||||||||
| 38 | 67 | my $in = $self->{+INPUT}; | |||||||||
| 39 | 67 | ▶ | return 0 unless ref $in; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 40 | 66 | ▶ | return 0 unless ref $got; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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
| |||||||||||
| 46 | |||||||||||
| 47 | # Don't let overloading mess with us. | ||||||||||
| 48 | 63 | return refaddr($in) == refaddr($got); | |||||||||
| 49 | } | ||||||||||
| 50 | |||||||||||
| 51 | 176 | 1; | |||||||||
| 52 | |||||||||||
| 53 | __END__ | ||||||||||