| 1 | package Test2::Event::Plan; | ||||||||||||||||||||||||||||
| 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{max directive reason}; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 455 | ▶ | use Carp qw/confess/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 455 | my %ALLOWED = ( | |||||||||||||||||||||||||||
| 14 | 'SKIP' => 1, | ||||||||||||||||||||||||||||
| 15 | 'NO PLAN' => 1, | ||||||||||||||||||||||||||||
| 16 | ); | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 1221 | ▶ | sub init { | ||||||||||||||||||||||||||
|
Subroutine
init: called CC=8 SCAR=20.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 19 | 1221 | ▶ | if ($_[0]->{+DIRECTIVE}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 20 | 66 | ▶ | $_[0]->{+DIRECTIVE} = 'SKIP' if $_[0]->{+DIRECTIVE} eq 'skip_all'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 21 | 66 | ▶ | $_[0]->{+DIRECTIVE} = 'NO PLAN' if $_[0]->{+DIRECTIVE} eq 'no_plan'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | confess "'" . $_[0]->{+DIRECTIVE} . "' is not a valid plan directive" | ||||||||||||||||||||||||||||
| 24 | 66 | ▶ | unless $ALLOWED{$_[0]->{+DIRECTIVE}}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||
| 26 | else { | ||||||||||||||||||||||||||||
| 27 | confess "Cannot have a reason without a directive!" | ||||||||||||||||||||||||||||
| 28 | 1155 | ▶ | if defined $_[0]->{+REASON}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | confess "No number of tests specified" | ||||||||||||||||||||||||||||
| 31 | 1154 | ▶ | unless defined $_[0]->{+MAX}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | confess "Plan test count '" . $_[0]->{+MAX} . "' does not appear to be a valid positive integer" | ||||||||||||||||||||||||||||
| 34 | 1153 | ▶ | unless $_[0]->{+MAX} =~ m/^\d+$/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 1152 | $_[0]->{+DIRECTIVE} = ''; | |||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 3 | ▶ | sub sets_plan { | ||||||||||||||||||||||||||
|
Subroutine
sets_plan: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 41 | 3 | my $self = shift; | |||||||||||||||||||||||||||
| 42 | return ( | ||||||||||||||||||||||||||||
| 43 | $self->{+MAX}, | ||||||||||||||||||||||||||||
| 44 | $self->{+DIRECTIVE}, | ||||||||||||||||||||||||||||
| 45 | 3 | $self->{+REASON}, | |||||||||||||||||||||||||||
| 46 | ); | ||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 212 | ▶ | sub terminate { | ||||||||||||||||||||||||||
|
Subroutine
terminate: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 50 | 212 | my $self = shift; | |||||||||||||||||||||||||||
| 51 | # On skip_all we want to terminate the hub | ||||||||||||||||||||||||||||
| 52 | 212 | ▶ | return 0 if $self->{+DIRECTIVE} && $self->{+DIRECTIVE} eq 'SKIP'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->{"directive"} and $self->{"directive"} eq "SKIP"
MC/DC100%2/2
$self->{"directive"} and $self->{"directive"} eq "SKIP"
$self->{"directive"}
$self->{"directive"} eq "SKIP"
Truth table100%3/3
A and B
A= $self->{"directive"}B= $self->{"directive"} eq "SKIP"
| |||||||||||||||||||||||||||||
| 53 | 211 | return undef; | |||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 3 | ▶ | sub summary { | ||||||||||||||||||||||||||
|
Subroutine
summary: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 57 | 3 | my $self = shift; | |||||||||||||||||||||||||||
| 58 | 3 | my $max = $self->{+MAX}; | |||||||||||||||||||||||||||
| 59 | 3 | my $directive = $self->{+DIRECTIVE}; | |||||||||||||||||||||||||||
| 60 | 3 | my $reason = $self->{+REASON}; | |||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 3 | ▶ | return "Plan is $max assertions" | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$max or not $directive
MC/DC50%1/2
$max or not $directive
$max
not $directive
Truth table66%2/3
A or not(B)
A= $maxB= not $directive
| |||||||||||||||||||||||||||||
| 63 | if $max || !$directive; | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 2 | ▶ | return "Plan is '$directive', $reason" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 66 | if $reason; | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 1 | return "Plan is '$directive'"; | |||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 3956 | ▶ | sub facet_data { | ||||||||||||||||||||||||||
|
Subroutine
facet_data: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||
| 72 | 3956 | my $self = shift; | |||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 3956 | my $out = $self->common_facet_data; | |||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | $out->{control}->{terminate} = $self->{+DIRECTIVE} eq 'SKIP' ? 0 : undef | ||||||||||||||||||||||||||||
| 77 | 3956 | ▶ | unless defined $out->{control}->{terminate}; | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 3956 | $out->{plan} = {count => $self->{+MAX}}; | |||||||||||||||||||||||||||
| 80 | 3956 | ▶ | $out->{plan}->{details} = $self->{+REASON} if defined $self->{+REASON}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 3956 | ▶ | if (my $dir = $self->{+DIRECTIVE}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 83 | 505 | ▶ | $out->{plan}->{skip} = 1 if $dir eq 'SKIP'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 84 | 505 | ▶ | $out->{plan}->{none} = 1 if $dir eq 'NO PLAN'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 3956 | return $out; | |||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | 455 | 1; | |||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | __END__ | ||||||||||||||||||||||||||||