| 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
| ||||||||||||||||||||||||||||||||||
| 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
| ||||||||||||||||||||||||||||||||||
| 34 | ||||||||||||||||||||||||||||||||||
| 35 | 202 | my $want = $self->{+INPUT}; | ||||||||||||||||||||||||||||||||
| 36 | ||||||||||||||||||||||||||||||||||
| 37 | 202 | ▶ | my $match = ($want xor $got) ? 0 : 1; | |||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%4/4
$want xor $got
MC/DC100%2/2
$want xor $got
$want
$got
Truth table100%4/4
A xor B
A= $wantB= $got
| ||||||||||||||||||||||||||||||||||
| 38 | 202 | ▶ | $match = $match ? 0 : 1 if $self->{+NEGATE}; | |||||||||||||||||||||||||||||||
|
Branch: 2 branches
| ||||||||||||||||||||||||||||||||||
| 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
| ||||||||||||||||||||||||||||||||||
| 46 | ||||||||||||||||||||||||||||||||||
| 47 | 82 | ▶ | my $dne = $delta->dne || ""; | |||||||||||||||||||||||||||||||
|
Condition100%2/2
$delta->dne || ''
MC/DC100%1/1
$delta->dne || ''
$delta->dne
Truth table100%2/2
A
A= $delta->dne
| ||||||||||||||||||||||||||||||||||
| 48 | 82 | ▶ | unless ($dne eq 'got') { | |||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||
| 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
| ||||||||||||||||||||||||||||||||||
| 59 | 165 | ▶ | my $val = defined $bool ? $bool : 'undef'; | |||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||
| 60 | 165 | ▶ | $val = "''" unless length($val); | |||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||
| 61 | ||||||||||||||||||||||||||||||||||
| 62 | 165 | return "<$name ($val)>"; | ||||||||||||||||||||||||||||||||
| 63 | } | |||||||||||||||||||||||||||||||||
| 64 | ||||||||||||||||||||||||||||||||||
| 65 | 171 | 1; | ||||||||||||||||||||||||||||||||
| 66 | ||||||||||||||||||||||||||||||||||
| 67 | __END__ | |||||||||||||||||||||||||||||||||