blib/lib/Test2/Compare/Bool.pm

filter: Statementstmt 100% 46 / 46 Branchbran 100% 20 / 20 Conditioncond 100% 6 / 6 MC/DCmcdc 100% 3 / 3 Subroutinesub 100% 11 / 11 Podpod 100% 4 / 4 totaltotal 100% 90 / 90 CC 13 SCAR 12.3
CC
13
Cov
100%
verify
6.0
run
4.0
_render_bool
4.0
CRAP 3.4
« blib/lib/Test2/Util/ExternalMeta.pm ↑ Summary blib/lib/Test2/Tools/Compare.pm »
1 package Test2::Compare::Bool;
2 171 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 171 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 171 ▶use Carp qw/confess/;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 171 ▶use base 'Test2::Compare::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 171 our $VERSION = '1.302226';
10  
11 171 ▶use Test2::Util::HashBase qw/input/;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 # Overloads '!' for us.
14 171 ▶use Test2::Compare::Negatable;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 84 ▶sub name {
Subroutine name: called CC=1 SCAR=0.0
Pod documented
17 84 my $self = shift;
18 84 my $in = $self->{+INPUT};
19 84 return _render_bool($in);
20 }
21  
22 84 ▶sub operator {
Subroutine operator: called CC=2 SCAR=6.9
Pod documented
23 84 my $self = shift;
24 84 ▶ return '!=' if $self->{+NEGATE};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"negate"} 42 42 84
25 42 return '==';
26 }
27  
28 203 ▶sub verify {
Subroutine verify: called CC=6 SCAR=17.9
Pod documented
29 203 my $self = shift;
30 203 my %params = @_;
31 203 my ($got, $exists) = @params{qw/got exists/};
32  
33 203 ▶ return 0 unless $exists;
Branch: 1 branch
BranchTrueFalseTotal
unless $exists 1 202 203
34  
35 202 my $want = $self->{+INPUT};
36  
37 202 ▶ my $match = ($want xor $got) ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
$want ^^ $got ? : 120 82 202
Condition100%4/4
$want xor $got
l&&rl&&!r!l&&r!l&&!r
50606032
MC/DC100%2/2
$want xor $got
$want $got
Truth table100%4/4
A xor B
A= $wantB= $got
ABresult
110
101
011
000
38 202 ▶ $match = $match ? 0 : 1 if $self->{+NEGATE};
Branch: 2 branches
BranchTrueFalseTotal
if $self->{"negate"} 121 81 202
$match ? : 41 80 121
39  
40 202 return $match;
41 }
42  
43 203 ▶sub run {
Subroutine run: called CC=4 SCAR=13.9
Pod documented
44 203 my $self = shift;
45 203 ▶ my $delta = $self->SUPER::run(@_) or return;
Branch: 1 branch
BranchTrueFalseTotal
my $delta = $self->SUPER::run(@_) or return 82 121 203
46  
47 82 ▶ my $dne = $delta->dne || "";
Condition100%2/2
$delta->dne || ''
l!l
181
MC/DC100%1/1
$delta->dne || ''
$delta->dne
Truth table100%2/2
A
A= $delta->dne
Aresult
11
00
48 82 ▶ unless ($dne eq 'got') {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dne eq "got") 81 1 82
49 81 my $got = $delta->got;
50 81 $delta->set_got(_render_bool($got));
51 }
52  
53 82 return $delta;
54 }
55  
56 165 ▶sub _render_bool {
Subroutine _render_bool: called CC=4 SCAR=13.9
57 165 my $bool = shift;
58 165 ▶ my $name = $bool ? 'TRUE' : 'FALSE';
Branch: 1 branch
BranchTrueFalseTotal
$bool ? : 91 74 165
59 165 ▶ my $val = defined $bool ? $bool : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $bool ? : 147 18 165
60 165 ▶ $val = "''" unless length($val);
Branch: 1 branch
BranchTrueFalseTotal
unless length $val 18 147 165
61  
62 165 return "<$name ($val)>";
63 }
64  
65 171 1;
66  
67 __END__
« blib/lib/Test2/Util/ExternalMeta.pm ↑ Summary blib/lib/Test2/Tools/Compare.pm »