blib/lib/Test2/Event/Ok.pm

filter: Statementstmt 100% 45 / 45 Branchbran 94.4% 17 / 18 Conditioncond 100% 11 / 11 MC/DCmcdc 100% 6 / 6 Subroutinesub 100% 12 / 12 Podpod 66.6% 4 / 6 totaltotal 96.9% 95 / 98 CC 14 SCAR 11.0
CC
14
Cov
99%
facet_data
4.0
init
4.0
summary
4.0
CRAP 3.0
« blib/lib/Test2/Compare/Meta.pm ↑ Summary blib/lib/Test2/Compare/Scalar.pm »
1 package Test2::Event::Ok;
2 455 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 455 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 455 our $VERSION = '1.302226';
6  
7  
8 455 ▶BEGIN { require Test2::Event; our @ISA = qw(Test2::Event) }
Subroutine BEGIN: called CC=1 SCAR=0.0
9 455 ▶use Test2::Util::HashBase qw{
Subroutine BEGIN: called CC=1 SCAR=0.0
10 pass effective_pass name todo
11 455 };
12  
13 3484 ▶sub init {
Subroutine init: called CC=4 SCAR=13.9
Pod undocumented
14 3484 my $self = shift;
15  
16 # Do not store objects here, only true or false
17 3484 ▶ $self->{+PASS} = $self->{+PASS} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->{'pass'} ? : 3359 125 3484
18 3484 ▶ $self->{+EFFECTIVE_PASS} = $self->{+PASS} || (defined($self->{+TODO}) ? 1 : 0);
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'todo'} ? : 8 117 125
Condition100%3/3
$self->{'pass'} || (defined $self->{'todo'} ? 1 : 0)
l!l&&r!l&&!r
33598117
MC/DC100%2/2
$self->{'pass'} || (defined $self->{'todo'} ? 1 : 0)
$self->{'pass'} (defined $self->{'todo'} ? 1 : 0)
Truth table100%3/3
A || B
A= $self->{'pass'}B= (defined $self->{'todo'} ? 1 : 0)
ABresult
1X1
011
000
19 }
20  
21 {
22 455 ▶ no warnings 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.0
23 327 ▶ sub set_todo {
Subroutine set_todo: called CC=2 SCAR=6.9
24 327 my $self = shift;
25 327 my ($todo) = @_;
26 327 $self->{+TODO} = $todo;
27 327 ▶ $self->{+EFFECTIVE_PASS} = defined($todo) ? 1 : $self->{+PASS};
Branch: 1 branch
BranchTrueFalseTotal
defined $todo ? : 326 1 327
28 }
29 }
30  
31 3 ▶sub increments_count { 1 };
Subroutine increments_count: called CC=1 SCAR=0.0
Pod documented
32  
33 4 ▶sub causes_fail { !$_[0]->{+EFFECTIVE_PASS} }
Subroutine causes_fail: called CC=1 SCAR=0.0
Pod documented
34  
35 7 ▶sub summary {
Subroutine summary: called CC=4 SCAR=13.9
Pod documented
36 7 my $self = shift;
37  
38 7 ▶ my $name = $self->{+NAME} || "Nameless Assertion";
Condition100%2/2
$self->{'name'} || 'Nameless Assertion'
l!l
61
MC/DC100%1/1
$self->{'name'} || 'Nameless Assertion'
$self->{'name'}
Truth table100%2/2
A
A= $self->{'name'}
Aresult
11
00
39  
40 7 my $todo = $self->{+TODO};
41 7 ▶ if ($todo) {
Branch: 2 branches
BranchTrueFalseTotal
if ($todo) { } 1 6 7
elsif (defined $todo) { } 1 5 6
42 1 $name .= " (TODO: $todo)";
43 }
44 elsif (defined $todo) {
45 1 $name .= " (TODO)"
46 }
47  
48 7 return $name;
49 }
50  
51 6980 ▶sub extra_amnesty {
Subroutine extra_amnesty: called CC=4 SCAR=13.9
Pod undocumented
52 6980 my $self = shift;
53 6980 ▶ return unless defined($self->{+TODO}) || ($self->{+EFFECTIVE_PASS} && !$self->{+PASS});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"todo"} or $self->{"effective_pass"} and not $self->{"pass"} 6504 476 6980
Condition100%6/6
defined $self->{"todo"} or $self->{"effective_pass"} and not $self->{"pass"}
l!l&&r!l&&!r
402746504
$self->{"effective_pass"} and not $self->{"pass"}
!ll&&!rl&&r
472603274
MC/DC100%3/3
defined $self->{"todo"} or $self->{"effective_pass"} and not $self->{"pass"}
defined $self->{"todo"} $self->{"effective_pass"} not $self->{"pass"}
Truth table100%4/4
A or B and not(C)
A= defined $self->{"todo"}B= $self->{"effective_pass"}C= not $self->{"pass"}
ABCresult
1XX1
0111
00X0
0100
54 return {
55 tag => 'TODO',
56 476 details => $self->{+TODO},
57 };
58 }
59  
60 7489 ▶sub facet_data {
Subroutine facet_data: called CC=4 SCAR=13.9
Pod documented
61 7489 my $self = shift;
62  
63 7489 my $out = $self->common_facet_data;
64  
65 $out->{assert} = {
66 no_debug => 1, # Legacy behavior
67 pass => $self->{+PASS},
68 7489 details => $self->{+NAME},
69 };
70  
71 7489 ▶ if (my @extra_amnesty = $self->extra_amnesty) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@extra_amnesty) = $self->extra_amnesty) 985 6504 7489
72 985 my %seen;
73  
74 # It is possible the extra amnesty can be a duplicate, so filter it.
75 $out->{amnesty} = [
76 1278 ▶ grep { !$seen{defined($_->{tag}) ? $_->{tag} : ''}->{defined($_->{details}) ? $_->{details} : ''}++ }
Branch: 2 branches
BranchTrueFalseTotal
defined $_->{'tag'} ? : 1278 0 1278
defined $_->{'details'} ? : 1204 74 1278
77 @extra_amnesty,
78 985 @{$out->{amnesty}},
79 ];
80 }
81  
82 7489 return $out;
83 }
84  
85 455 1;
86  
87 __END__
« blib/lib/Test2/Compare/Meta.pm ↑ Summary blib/lib/Test2/Compare/Scalar.pm »