| 1 | package Test::Pcuke::Gherkin::Node::Table::Row; | ||||||||||||||||||||||||||||
| 2 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 4 | ▶ | use base 'Test::Pcuke::Gherkin::Node'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 4 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | =head1 NAME | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | Test::Pcuke::Gherkin::Node::Table::Row - row of the table wrapper object | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | TODO SYNOPSIS | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | use Test::Pcuke::Gherkin::Node::Table::Row; | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | my $row = Test::Pcuke::Gherkin::Node::Table::Row->new(); | ||||||||||||||||||||||||||||
| 20 | # TODO code example | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | =head1 METHODS | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | =head2 new | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | =cut | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 3 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 29 | 3 | my ($class, $args) = @_; | |||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 3 | $args->{'_nsteps'} = {pass=>0, fail=>0, undef=>0}; | |||||||||||||||||||||||||||
| 32 | 3 | $args->{'_nscenarios'} = {pass=>0, fail=>0, undef=>0}; | |||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 3 | my $instance = $class->SUPER::new( | |||||||||||||||||||||||||||
| 35 | immutables => [qw{data executor}], | ||||||||||||||||||||||||||||
| 36 | properties => [qw{_nsteps _nscenarios}], | ||||||||||||||||||||||||||||
| 37 | args => $args | ||||||||||||||||||||||||||||
| 38 | ); | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 3 | return $instance; | |||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 2 | ▶ | sub set_data { | ||||||||||||||||||||||||||
|
Subroutine
set_data: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 44 | 2 | my ($self, $hash) = @_; | |||||||||||||||||||||||||||
| 45 | 2 | $self->_set_immutable('data', $hash); | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 3 | ▶ | sub data { $_[0]->_get_immutable('data') } | ||||||||||||||||||||||||||
|
Subroutine
data: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 5 | ▶ | sub nsteps { | ||||||||||||||||||||||||||
|
Subroutine
nsteps: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 51 | 5 | my ($self, $status) = @_; | |||||||||||||||||||||||||||
| 52 | 5 | my $nsteps = $self->_get_property('_nsteps'); | |||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | return $status ? | ||||||||||||||||||||||||||||
| 55 | 5 | ▶ | $nsteps->{$status} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 56 | : $nsteps; | ||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 1 | ▶ | sub nscenarios { | ||||||||||||||||||||||||||
|
Subroutine
nscenarios: called CC=4 SCAR=17.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 60 | 1 | my ($self, $status) = @_; | |||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 1 | my $nscenarios; | |||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 1 | ▶ | if ( $self->nsteps('fail') > 0 ) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 65 | 1 | $nscenarios = {fail => 1, pass => 0, undef => 0}; | |||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | elsif ( $self->nsteps('undef') > 0 ) { | ||||||||||||||||||||||||||||
| 68 | 0 | $nscenarios = {fail => 0, pass => 0, undef => 1}; | |||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | else { | ||||||||||||||||||||||||||||
| 71 | 0 | $nscenarios = {fail => 0, pass => 1, undef => 0}; | |||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | return $status ? | ||||||||||||||||||||||||||||
| 75 | 1 | ▶ | $nscenarios->{$status} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 76 | : $nscenarios; | ||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 0 | ▶ | sub set_executor { $_[0]->_set_immutable('executor', $_[1] ) } | ||||||||||||||||||||||||||
|
Subroutine
set_executor: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 80 | 1 | ▶ | sub executor { $_[0]->_get_immutable('executor') } | ||||||||||||||||||||||||||
|
Subroutine
executor: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 1 | ▶ | sub execute { | ||||||||||||||||||||||||||
|
Subroutine
execute: called CC=6 SCAR=18.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 83 | 1 | my ($self, $steps, $background) = @_; | |||||||||||||||||||||||||||
| 84 | 1 | my $status; | |||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | 1 | ▶ | if ( $self->executor && $self->executor->can('reset_world') ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->executor and $self->executor->can("reset_world")
MC/DC0%0/2
$self->executor and $self->executor->can("reset_world")
$self->executor
$self->executor->can("reset_world")
Truth table33%1/3
A and B
A= $self->executorB= $self->executor->can("reset_world")
| |||||||||||||||||||||||||||||
| 87 | 0 | $self->executor->reset_world; | |||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | 1 | ▶ | if ($background) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 91 | 1 | $background->execute; | |||||||||||||||||||||||||||
| 92 | 1 | $self->collect_stats($background); | |||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | 1 | foreach my $s ( @$steps ) { | |||||||||||||||||||||||||||
| 96 | 2 | $s->set_params( $self->data ); | |||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | 2 | $s->execute(); | |||||||||||||||||||||||||||
| 99 | 2 | $self->collect_stats( $s ); | |||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | # TODO move this to collect_stats | ||||||||||||||||||||||||||||
| 102 | 2 | for ( @{ $s->param_names } ) { | |||||||||||||||||||||||||||
| 103 | 2 | push @{ $status->{$_}->{status} }, $s->status; | |||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | 2 | $s->unset_params; | |||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | 1 | $self->_set_status($status); | |||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | 3 | ▶ | sub collect_stats { | ||||||||||||||||||||||||||
|
Subroutine
collect_stats: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 114 | 3 | my ($self, $step) = @_; | |||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | 3 | my $nsteps = $self->nsteps; | |||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | 3 | ▶ | if ( $step->can('nsteps') ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 119 | #background | ||||||||||||||||||||||||||||
| 120 | 1 | my $bg_nsteps = $step->nsteps; | |||||||||||||||||||||||||||
| 121 | 1 | for (qw{pass fail undef}) { | |||||||||||||||||||||||||||
| 122 | 3 | $nsteps->{$_} += $bg_nsteps->{$_}; | |||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||
| 125 | else { | ||||||||||||||||||||||||||||
| 126 | #step | ||||||||||||||||||||||||||||
| 127 | 2 | $nsteps->{ $step->status }++; | |||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | 3 | $self->_set_property('_nsteps', $nsteps); | |||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | 1 | ▶ | sub _set_status { | ||||||||||||||||||||||||||
|
Subroutine
_set_status: called CC=8 SCAR=30.5
| |||||||||||||||||||||||||||||
| 134 | 1 | my ($self, $status) = @_; | |||||||||||||||||||||||||||
| 135 | 1 | my $final_status; | |||||||||||||||||||||||||||
| 136 | my $exceptions; | ||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | 1 | for my $p ( keys %$status ) { | |||||||||||||||||||||||||||
| 139 | 2 | for my $s ( @{ $status->{$p}->{status} } ) { | |||||||||||||||||||||||||||
| 140 | 2 | ▶ | if ( ! $final_status->{$p} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 141 | 2 | $final_status->{$p} = $s; | |||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||
| 143 | else { | ||||||||||||||||||||||||||||
| 144 | 0 | ▶ | $final_status->{$p} = $s if $s eq 'undef' && $final_status->{$p} eq 'pass'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$s eq "undef" and $final_status->{$p} eq "pass"
MC/DC0%0/2
$s eq "undef" and $final_status->{$p} eq "pass"
$s eq "undef"
$final_status->{$p} eq "pass"
Truth table0%0/3
A and B
A= $s eq "undef"B= $final_status->{$p} eq "pass"
| |||||||||||||||||||||||||||||
| 145 | 0 | ▶ | $final_status->{$p} = $s if $s eq 'fail'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 146 | 0 | ▶ | last if $s eq 'fail'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | 1 | $self->_set_property('status', $final_status); | |||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | 3 | ▶ | sub status { $_[0]->_get_property('status') } | ||||||||||||||||||||||||||
|
Subroutine
status: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | 2 | ▶ | sub column_status { | ||||||||||||||||||||||||||
|
Subroutine
column_status: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 157 | 2 | my ($self, $param_name) = @_; | |||||||||||||||||||||||||||
| 158 | 2 | my $status = $self->status; | |||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | 2 | return $status->{$param_name}; | |||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | 4 | 1; # End of Test::Pcuke::Gherkin::Node::Table::Row | |||||||||||||||||||||||||||
| 165 | __END__ | ||||||||||||||||||||||||||||