| 1 | package TAP::Tree::Iterator; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use v5.10.1; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use utf8; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 3 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 4 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 11 | 4 | my $class = shift; | |||||||||||||||||||||||||||
| 12 | 4 | my %params = @_; | |||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 4 | my ( $pkg, undef, undef ) = caller; | |||||||||||||||||||||||||||
| 15 | 4 | ▶ | if ( $pkg ne 'TAP::Tree' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 16 | 0 | croak "Invalid call! This module must be called from inside TAP::Tree."; | |||||||||||||||||||||||||||
| 17 | } | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | my $self = { | ||||||||||||||||||||||||||||
| 20 | tap_tree => $params{tap_tree}, | ||||||||||||||||||||||||||||
| 21 | subtest => $params{subtest}, | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 4 | index_recursive => [], | |||||||||||||||||||||||||||
| 24 | index_testline => 0, | ||||||||||||||||||||||||||||
| 25 | }; | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 4 | bless $self, $class; | |||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 4 | return $self; | |||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 24 | ▶ | sub next { | ||||||||||||||||||||||||||
|
Subroutine
next: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 33 | 24 | my $self = shift; | |||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 24 | ▶ | my $next = ( $self->{subtest} ) ? $self->_next_subtest : $self->_next; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 24 | return $next; | |||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 21 | ▶ | sub _next_subtest { | ||||||||||||||||||||||||||
|
Subroutine
_next_subtest: called CC=11 SCAR=24.0
| |||||||||||||||||||||||||||||
| 41 | 21 | my $self = shift; | |||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 21 | ▶ | return if ( ! defined $self->{index_testline} ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | # get current test | ||||||||||||||||||||||||||||
| 46 | my $test = { | ||||||||||||||||||||||||||||
| 47 | plan => $self->{tap_tree}{plan}, | ||||||||||||||||||||||||||||
| 48 | testline => $self->{tap_tree}{testline}, | ||||||||||||||||||||||||||||
| 49 | 19 | }; | |||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 19 | for my $index ( @{ $self->{index_recursive} } ) { | |||||||||||||||||||||||||||
| 52 | 17 | my $current = $test->{testline}[$index]{subtest}; | |||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 17 | $test = $current; | |||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | # get current testline | ||||||||||||||||||||||||||||
| 58 | my $testline = ( defined $test->{testline}[$self->{index_testline}] ) ? | ||||||||||||||||||||||||||||
| 59 | 19 | ▶ | $test->{testline}[$self->{index_testline}] : undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | my $next = { | ||||||||||||||||||||||||||||
| 62 | test => $test, | ||||||||||||||||||||||||||||
| 63 | testline => $testline, | ||||||||||||||||||||||||||||
| 64 | 19 | indent => scalar @{ $self->{index_recursive} }, | |||||||||||||||||||||||||||
| 65 | }; | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | # set next index | ||||||||||||||||||||||||||||
| 68 | 19 | ▶ | if ( $testline && $testline->{subtest} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$testline and $testline->{"subtest"}
MC/DC50%1/2
$testline and $testline->{"subtest"}
$testline
$testline->{"subtest"}
Truth table66%2/3
A and B
A= $testlineB= $testline->{"subtest"}
| |||||||||||||||||||||||||||||
| 69 | 8 | push @{ $self->{index_recursive} }, $self->{index_testline}; | |||||||||||||||||||||||||||
| 70 | 8 | $self->{index_testline} = 0; | |||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 8 | return $next; | |||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 11 | ▶ | if ( defined $test->{testline}[$self->{index_testline} + 1 ] ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 76 | 4 | $self->{index_testline} += 1; | |||||||||||||||||||||||||||
| 77 | 4 | return $next; | |||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | 7 | my $found; | |||||||||||||||||||||||||||
| 81 | 7 | ▶ | while ( @{ $self->{index_recursive} } ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 82 | 8 | my $index_next = pop @{ $self->{index_recursive} }; | |||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | my $nexttest = { | ||||||||||||||||||||||||||||
| 85 | testline => $self->{tap_tree}{testline}, | ||||||||||||||||||||||||||||
| 86 | 8 | }; | |||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 8 | for my $i ( @{ $self->{index_recursive} } ) { | |||||||||||||||||||||||||||
| 89 | 5 | my $current = $nexttest->{testline}[$i]{subtest}; | |||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | 5 | $nexttest = $current; | |||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 8 | ▶ | if ( defined $nexttest->{testline}[$index_next + 1] ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 95 | 4 | $found = $index_next + 1; | |||||||||||||||||||||||||||
| 96 | 4 | last; | |||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | 7 | ▶ | if ( $found ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 101 | 4 | $self->{index_testline} = $found; | |||||||||||||||||||||||||||
| 102 | } else { | ||||||||||||||||||||||||||||
| 103 | 3 | $self->{index_testline} = undef; | |||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | 7 | return $next; | |||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | 3 | ▶ | sub _next { | ||||||||||||||||||||||||||
|
Subroutine
_next: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 110 | 3 | my $self = shift; | |||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | my $test = { | ||||||||||||||||||||||||||||
| 113 | plan => $self->{tap_tree}{plan}, | ||||||||||||||||||||||||||||
| 114 | testline => $self->{tap_tree}{testline}, | ||||||||||||||||||||||||||||
| 115 | 3 | }; | |||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | 3 | ▶ | if ( defined $self->{tap_tree}{testline}[$self->{index_testline}] ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 118 | 2 | my $testline = $self->{tap_tree}{testline}[$self->{index_testline}]; | |||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | 2 | $self->{index_testline}++; | |||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | 2 | return { test => $test, testline => $testline, indent => 0 }; | |||||||||||||||||||||||||||
| 123 | } else { | ||||||||||||||||||||||||||||
| 124 | 1 | return; | |||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | 3 | 1; | |||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | __END__ | ||||||||||||||||||||||||||||