blib/lib/Test2/Compare/String.pm

filter: Statementstmt 100% 42 / 42 Branchbran 100% 14 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 11 / 11 Podpod 60.0% 3 / 5 totaltotal 97.2% 70 / 72 CC 8 SCAR 8.9
CC
8
Cov
100%
operator
4.0
verify
4.0
init
2.0
CRAP 2.4
« blib/lib/Test2/Tools/Exception.pm ↑ Summary blib/lib/Test2/Compare/Event.pm »
1 package Test2::Compare::String;
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 Carp qw/confess/;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 176 ▶use base 'Test2::Compare::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 176 our $VERSION = '1.302226';
10  
11 176 ▶use Test2::Util::HashBase qw/input/;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 # Overloads '!' for us.
14 176 ▶use Test2::Compare::Negatable;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 64 ▶sub stringify_got { 1 }
Subroutine stringify_got: called CC=1 SCAR=0.0
Pod undocumented
17  
18 7239 ▶sub init {
Subroutine init: called CC=2 SCAR=6.9
Pod undocumented
19 7239 my $self = shift;
20 confess "input must be defined for 'String' check"
21 7239 ▶ unless defined $self->{+INPUT};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"input"} 1 7238 7239
22  
23 7238 $self->SUPER::init(@_);
24 }
25  
26 91 ▶sub name {
Subroutine name: called CC=1 SCAR=0.0
Pod documented
27 91 my $self = shift;
28 91 my $in = $self->{+INPUT};
29 91 return "$in";
30 }
31  
32 104 ▶sub operator {
Subroutine operator: called CC=4 SCAR=13.9
Pod documented
33 104 my $self = shift;
34  
35 104 ▶ return '' unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 23 81 104
36 81 my ($got) = @_;
37  
38 81 ▶ return '' unless defined($got);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $got 7 74 81
39  
40 74 ▶ return 'ne' if $self->{+NEGATE};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"negate"} 3 71 74
41 71 return 'eq';
42 }
43  
44 9231 ▶sub verify {
Subroutine verify: called CC=4 SCAR=13.9
Pod documented
45 9231 my $self = shift;
46 9231 my %params = @_;
47 9231 my ($got, $exists) = @params{qw/got exists/};
48  
49 9231 ▶ return 0 unless $exists;
Branch: 1 branch
BranchTrueFalseTotal
unless $exists 22 9209 9231
50 9209 ▶ return 0 unless defined $got;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $got 11 9198 9209
51  
52 9198 my $input = $self->{+INPUT};
53 9198 my $negate = $self->{+NEGATE};
54  
55 9198 ▶ return "$input" ne "$got" if $negate;
Branch: 1 branch
BranchTrueFalseTotal
if $negate 8 9190 9198
56 9190 return "$input" eq "$got";
57 }
58  
59 176 1;
60  
61 __END__
« blib/lib/Test2/Tools/Exception.pm ↑ Summary blib/lib/Test2/Compare/Event.pm »