| 1 | package Test2::Compare::Pattern; | ||||||||||||||||||||||||||||
| 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/pattern stringify_got/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | # Overloads '!' for us. | ||||||||||||||||||||||||||||
| 12 | 176 | ▶ | use Test2::Compare::Negatable; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 176 | ▶ | use Carp qw/croak/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 462 | ▶ | sub init { | ||||||||||||||||||||||||||
|
Subroutine
init: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 17 | 462 | my $self = shift; | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 462 | ▶ | croak "'pattern' is a required attribute" unless $self->{+PATTERN}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 461 | ▶ | $self->{+STRINGIFY_GOT} ||= 0; | ||||||||||||||||||||||||||
|
Condition100%2/2
$self->{"stringify_got"} ||= 0
MC/DC100%1/1
$self->{"stringify_got"} ||= 0
$self->{"stringify_got"}
Truth table100%2/2
A
A= $self->{"stringify_got"}
| |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 461 | $self->SUPER::init(); | |||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 22 | ▶ | sub name { shift->{+PATTERN} . "" } | ||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 27 | 22 | ▶ | sub operator { shift->{+NEGATE} ? '!~' : '=~' } | ||||||||||||||||||||||||||
|
Subroutine
operator: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 515 | ▶ | sub verify { | ||||||||||||||||||||||||||
|
Subroutine
verify: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 30 | 515 | my $self = shift; | |||||||||||||||||||||||||||
| 31 | 515 | my %params = @_; | |||||||||||||||||||||||||||
| 32 | 515 | my ($got, $exists) = @params{qw/got exists/}; | |||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 515 | ▶ | return 0 unless $exists; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | 513 | ▶ | return 0 unless defined($got); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 36 | 511 | ▶ | return 0 if ref $got && !$self->stringify_got; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
ref $got and not $self->stringify_got
MC/DC100%2/2
ref $got and not $self->stringify_got
ref $got
not $self->stringify_got
Truth table100%3/3
A and not(B)
A= ref $gotB= not $self->stringify_got
| |||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | return $got !~ $self->{+PATTERN} | ||||||||||||||||||||||||||||
| 39 | 509 | ▶ | if $self->{+NEGATE}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 495 | return $got =~ $self->{+PATTERN}; | |||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 176 | 1; | |||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | __END__ | ||||||||||||||||||||||||||||