| 1 | package Test2::Compare::Condition; | ||||||||||||||
| 2 | 2 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | |||||||||||||||
| 5 | 2 | ▶ | use base 'Test2::Compare::Base'; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 6 | |||||||||||||||
| 7 | 2 | ▶ | use Carp qw/croak/; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 8 | |||||||||||||||
| 9 | 2 | ▶ | use Test2::Util::HashBase qw/code/; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 10 | |||||||||||||||
| 11 | # Overloads '!' for us. | ||||||||||||||
| 12 | 2 | ▶ | use Test2::Compare::Negatable; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 13 | |||||||||||||||
| 14 | 11 | ▶ | sub init { | ||||||||||||
|
Subroutine
init: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||
| 15 | 11 | my $self = shift; | |||||||||||||
| 16 | |||||||||||||||
| 17 | 11 | ▶ | croak "'code' must be a code reference" unless ref $self->{+CODE} eq 'CODE'; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 18 | |||||||||||||||
| 19 | 11 | $self->SUPER::init(); | |||||||||||||
| 20 | } | ||||||||||||||
| 21 | |||||||||||||||
| 22 | 2 | ▶ | sub operator { | ||||||||||||
|
Subroutine
operator: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||
| 23 | 2 | my $self = shift; | |||||||||||||
| 24 | 2 | ▶ | return '!=' if $self->{+NEGATE}; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 25 | 1 | return '=='; | |||||||||||||
| 26 | } | ||||||||||||||
| 27 | |||||||||||||||
| 28 | 2 | ▶ | sub name { '<CONDITION>' } | ||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 29 | |||||||||||||||
| 30 | 13 | ▶ | sub verify { | ||||||||||||
|
Subroutine
verify: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||
| 31 | 13 | my $self = shift; | |||||||||||||
| 32 | 13 | my %params = @_; | |||||||||||||
| 33 | 13 | my ($got, $exists) = @params{qw/got exists/}; | |||||||||||||
| 34 | |||||||||||||||
| 35 | 13 | ▶ | return 0 unless $params{exists}; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 36 | |||||||||||||||
| 37 | 13 | local $_ = $got; | |||||||||||||
| 38 | 13 | my $cond = $self->{+CODE}->(); | |||||||||||||
| 39 | 13 | ▶ | $cond = $cond ? 0 : 1 if $self->{+NEGATE}; | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 40 | |||||||||||||||
| 41 | 13 | return $cond; | |||||||||||||
| 42 | } | ||||||||||||||
| 43 | |||||||||||||||
| 44 | 13 | ▶ | sub run { | ||||||||||||
|
Subroutine
run: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||
| 45 | 13 | my $self = shift; | |||||||||||||
| 46 | 13 | ▶ | my $delta = $self->SUPER::run(@_) or return; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 47 | |||||||||||||||
| 48 | 4 | ▶ | my $dne = $delta->dne || ""; | ||||||||||||
|
Condition50%1/2
$delta->dne || ''
MC/DC0%0/1
$delta->dne || ''
$delta->dne
Truth table50%1/2
A
A= $delta->dne
| |||||||||||||||
| 49 | 4 | ▶ | unless ($dne eq 'got') { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 50 | 4 | my $got = $delta->got; | |||||||||||||
| 51 | 4 | $delta->set_got(_render_bool($got)); | |||||||||||||
| 52 | } | ||||||||||||||
| 53 | |||||||||||||||
| 54 | 4 | return $delta; | |||||||||||||
| 55 | } | ||||||||||||||
| 56 | |||||||||||||||
| 57 | 4 | ▶ | sub _render_bool { | ||||||||||||
|
Subroutine
_render_bool: called CC=4 SCAR=14.1
| |||||||||||||||
| 58 | 4 | my $bool = shift; | |||||||||||||
| 59 | 4 | ▶ | my $name = $bool ? 'TRUE' : 'FALSE'; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 60 | 4 | ▶ | my $val = defined $bool ? $bool : 'undef'; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 61 | 4 | ▶ | $val = "''" unless length($val); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 62 | |||||||||||||||
| 63 | 4 | return "<$name ($val)>"; | |||||||||||||
| 64 | } | ||||||||||||||
| 65 | |||||||||||||||
| 66 | 2 | 1; | |||||||||||||