| 1 | package Outthentic::DSL; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 2 | our $VERSION = '0.2.10'; | |||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use Outthentic::DSL::Context::Range; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use Outthentic::DSL::Context::Default; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 2 | ▶ | use Outthentic::DSL::Context::TextBlock; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 2 | ▶ | use File::Temp qw/ tempfile /; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | ▶ | use JSON; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | 2 | $Data::Dumper::Terse=1; | |||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | ▶ | sub results { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
results: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | 1 | $self->{results}; | |||||||||||||||||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | 1 | ▶ | sub add_result { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_result: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 27 | 1 | my $item = shift; | |||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | 1 | push @{$self->results}, { %{$item}, type => 'check_expression' }; | |||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | sub debug { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
debug: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | my $item = shift; | |||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | push @{$self->results}, { message => $item , type => 'debug' }; | |||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | 2 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | 2 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 46 | 2 | my $output = shift; | |||||||||||||||||||||||||||||||||||||||||
| 47 | 2 | ▶ | my $opts = shift || {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() || {}
MC/DC0%0/1
shift() || {}
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | bless { | ||||||||||||||||||||||||||||||||||||||||||
| 50 | results => [], | ||||||||||||||||||||||||||||||||||||||||||
| 51 | original_context => [], | ||||||||||||||||||||||||||||||||||||||||||
| 52 | current_context => [], | ||||||||||||||||||||||||||||||||||||||||||
| 53 | context_modificator => Outthentic::DSL::Context::Default->new(), | ||||||||||||||||||||||||||||||||||||||||||
| 54 | has_context => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 55 | succeeded => [], | ||||||||||||||||||||||||||||||||||||||||||
| 56 | captures => [], | ||||||||||||||||||||||||||||||||||||||||||
| 57 | within_mode => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 58 | block_mode => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 59 | last_match_line => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 60 | last_check_status => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 61 | debug_mod => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 62 | output => $output||'', | ||||||||||||||||||||||||||||||||||||||||||
| 63 | match_l => 40, | ||||||||||||||||||||||||||||||||||||||||||
| 64 | stream => {}, | ||||||||||||||||||||||||||||||||||||||||||
| 65 | languages => {}, | ||||||||||||||||||||||||||||||||||||||||||
| 66 | 2 | ▶ | %{$opts}, | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$output || ''
MC/DC0%0/1
$output || ''
$output
Truth table50%1/2
A
A= $output
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | }, __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | 1 | ▶ | sub create_context { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_context: called CC=6 SCAR=18.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||
| 73 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | 1 | ▶ | return if $self->{has_context}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 1 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | 1 | my @original_context = (); | |||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | 1 | for my $l ( split /\n/, $self->{output} ){ | |||||||||||||||||||||||||||||||||||||||||
| 82 | 1 | chomp $l; | |||||||||||||||||||||||||||||||||||||||||
| 83 | 1 | $i++; | |||||||||||||||||||||||||||||||||||||||||
| 84 | 1 | ▶ | $l=":blank_line" unless $l=~/\S/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 85 | 1 | push @original_context, [$l, $i]; | |||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | 1 | ▶ | $self->debug("[oc] [$l, $i]") if $self->{debug_mod} >= 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | 1 | $self->{original_context} = [@original_context]; | |||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||
| 93 | 1 | $self->{current_context} = [@original_context]; | |||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||
| 95 | 1 | ▶ | $self->debug('context populated') if $self->{debug_mod} >= 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | 1 | $self->{has_context} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | sub reset_context { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reset_context: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | $self->{current_context} = $self->{original_context}; | |||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | $self->debug('reset search context') if $self->{debug_mod} >= 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | $self->{context_modificator} = Outthentic::DSL::Context::Default->new(); | |||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||
| 116 | 1 | ▶ | sub reset_captures { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reset_captures: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||
| 118 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 119 | 1 | $self->{captures} = []; | |||||||||||||||||||||||||||||||||||||||||
| 120 | 1 | ▶ | unlink $self->{cache_dir}."/captures.json" if -f $self->{cache_dir}."/captures.json"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | 1 | ▶ | sub reset_succeeded { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reset_succeeded: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 126 | 1 | $self->{succeeded} = []; | |||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | sub stream { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stream: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | my @stream; | |||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | my $i=0; | |||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | for my $cid ( sort { $a <=> $b } keys %{$self->{stream}} ){ | |||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | $stream[$i]=[]; | |||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | for my $c (@{$self->{stream}->{$cid}}){ | |||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | push @{$stream[$i]}, $c->[0]; | |||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | $self->debug("[stream {$cid}] $c->[0]") if $self->{debug_mod} >= 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | $i++; | |||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | [@stream] | |||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | ▶ | sub match_lines { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
match_lines: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | return $self->{succeeded}; | |||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||
| 155 | 1 | ▶ | sub check_line { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_line: called CC=29 SCAR=54.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||
| 157 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 158 | 1 | my $pattern = shift; | |||||||||||||||||||||||||||||||||||||||||
| 159 | 1 | my $check_type = shift; | |||||||||||||||||||||||||||||||||||||||||
| 160 | 1 | my $message = shift; | |||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||
| 162 | 1 | my $status = 0; | |||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||
| 164 | 1 | s/\s+$// for $pattern; | |||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||
| 166 | 1 | $self->reset_captures; | |||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||
| 168 | 1 | my @captures = (); | |||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||
| 170 | 1 | $self->create_context; | |||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||
| 172 | 1 | ▶ | $self->debug("[lookup] $pattern ...") if $self->{debug_mod} >= 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||
| 174 | 1 | my @original_context = @{$self->{original_context}}; | |||||||||||||||||||||||||||||||||||||||||
| 175 | 1 | my @context_new = (); | |||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||
| 177 | # dynamic context | ||||||||||||||||||||||||||||||||||||||||||
| 178 | my $dc = $self->{context_modificator}->change_context( | ||||||||||||||||||||||||||||||||||||||||||
| 179 | $self->{current_context}, | ||||||||||||||||||||||||||||||||||||||||||
| 180 | $self->{original_context}, | ||||||||||||||||||||||||||||||||||||||||||
| 181 | $self->{succeeded} | ||||||||||||||||||||||||||||||||||||||||||
| 182 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||
| 184 | $self->debug("context modificator applied: ".(ref $self->{context_modificator})) | ||||||||||||||||||||||||||||||||||||||||||
| 185 | 1 | ▶ | if $self->{debug_mod} >=2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||
| 187 | 1 | ▶ | if ( $self->{debug_mod} >= 2 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | for my $dcl (@$dc){ | |||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | $self->debug("[dc] $dcl->[0]"); | |||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||
| 192 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||
| 195 | 1 | $self->reset_succeeded; | |||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||
| 197 | 1 | ▶ | if ($check_type eq 'default'){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 198 | 1 | for my $c (@{$dc}){ | |||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||
| 200 | 1 | my $ln = $c->[0]; | |||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | 1 | ▶ | next if $ln =~/#dsl_note:/; # skip debug entries | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||
| 204 | 1 | ▶ | if ( index($ln,$pattern) != -1){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | $status = 1; | |||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | $self->{last_match_line} = $ln; | |||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | push @{$self->{succeeded}}, $c; | |||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||
| 211 | }elsif($check_type eq 'regexp'){ | ||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | for my $c (@{$dc}) { | |||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | my $re = qr/$pattern/; | |||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | my $ln = $c->[0]; | |||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | ▶ | next if $ln eq ":blank_line"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | ▶ | next if $ln =~/#dsl_note:/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | my @foo = ($ln =~ /$re/g); | |||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | ▶ | if (scalar @foo){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | push @captures, [@foo]; | |||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | $status = 1; | |||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | push @{$self->{succeeded}}, $c; | |||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | ▶ | push @context_new, $c if $self->{within_mode}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | $self->{last_match_line} = $ln; | |||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||||||||||||
| 234 | }else { | ||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | confess "unknown check_type: $check_type"; | |||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||
| 240 | 1 | $self->{last_check_status} = $status; | |||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||
| 242 | 1 | ▶ | if ( $self->{debug_mod} >= 2 ){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | my $i = 1; | |||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | my $j = 1; | |||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | for my $cpp (@captures){ | |||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | for my $cp (@{$cpp}){ | |||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | $self->debug("CAP[$i,$j]: $cp"); | |||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | $j++; | |||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | $i++; | |||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | $j=1; | |||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | for my $s (@{$self->{succeeded}}){ | |||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | $self->debug("SUCC: $s->[0]"); | |||||||||||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||
| 260 | 1 | $self->{captures} = [ @captures ]; | |||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||
| 262 | 1 | ▶ | if ($self->{cache_dir}){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 263 | open CAPTURES, '>', $self->{cache_dir}.'/captures.json' | ||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | ▶ | or confess "can't open ".($self->{cache_dir})."captures.json to write $!"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | print CAPTURES encode_json($self->{captures}); | |||||||||||||||||||||||||||||||||||||||||
| 266 | $self->debug("CAPTURES saved at ".$self->{cache_dir}.'/captures.json') | ||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | ▶ | if $self->{debug_mod} >= 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | close CAPTURES; | |||||||||||||||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||
| 271 | # update context | ||||||||||||||||||||||||||||||||||||||||||
| 272 | 1 | ▶ | if ( $self->{within_mode} and $status ){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
$self->{"within_mode"} and $status
MC/DC0%0/2
$self->{"within_mode"} and $status
$self->{"within_mode"}
$status
Truth table33%1/3
A and B
A= $self->{"within_mode"}B= $status
| |||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | $self->{current_context} = [@context_new]; | |||||||||||||||||||||||||||||||||||||||||
| 274 | $self->debug("[WITH] within mode: modify search context to: $context_new[0][0]") | ||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | ▶ | if $self->{debug_mod} >= 2 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 276 | ▶ | }elsif ( $self->{within_mode} and ! $status ){ | |||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{"within_mode"} and not $status
MC/DC0%0/2
$self->{"within_mode"} and not $status
$self->{"within_mode"}
not $status
Truth table33%1/3
A and not(B)
A= $self->{"within_mode"}B= not $status
| |||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | $self->{current_context} = []; # empty context if within expression has not passed | |||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | ▶ | $self->debug('within mode: modify search context to: '.(Dumper([@context_new]))) if $self->{debug_mod} >= 2 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||
| 281 | 1 | $self->add_result({ status => $status , message => $message }); | |||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||
| 284 | $self->{context_modificator}->update_stream( | ||||||||||||||||||||||||||||||||||||||||||
| 285 | $self->{current_context}, | ||||||||||||||||||||||||||||||||||||||||||
| 286 | $self->{original_context}, | ||||||||||||||||||||||||||||||||||||||||||
| 287 | $self->{succeeded}, | ||||||||||||||||||||||||||||||||||||||||||
| 288 | 1 | \($self->{stream}), | |||||||||||||||||||||||||||||||||||||||||
| 289 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||
| 291 | 1 | return $status; | |||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||
| 295 | 1 | ▶ | sub validate { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
validate: called CC=54 SCAR=71.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||
| 297 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 298 | 1 | my $check_list = shift; | |||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||
| 300 | 1 | my $block_type; | |||||||||||||||||||||||||||||||||||||||||
| 301 | my @multiline_block; | ||||||||||||||||||||||||||||||||||||||||||
| 302 | 1 | my $here_str_mode = 0; | |||||||||||||||||||||||||||||||||||||||||
| 303 | 1 | my $here_str_marker; | |||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||
| 305 | my @lines; | ||||||||||||||||||||||||||||||||||||||||||
| 306 | 1 | ▶ | if ( -f $check_list ){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | ▶ | open my $ff, $check_list or die "can't open file check_list to read: $!"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | ▶ | while (my $ii = <$ff>){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | push @lines, $ii; | |||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | close $ff; | |||||||||||||||||||||||||||||||||||||||||
| 312 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | ▶ | @lines = ( ref $check_list ) ? @{$check_list} : ( split "\n", $check_list ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||
| 316 | 1 | LINE: for my $l ( @lines ) { | |||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||
| 318 | 1 | chomp $l; | |||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||
| 320 | 1 | ▶ | $self->debug("[dsl::$block_type] $l") if $self->{debug_mod} >= 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||
| 322 | 1 | ▶ | next LINE unless $l =~ /\S/; # skip blank lines | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||
| 324 | 1 | ▶ | next LINE if $l=~ /^\s*#(.*)/; # skip comments | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||
| 326 | 1 | ▶ | if ($here_str_mode && $l=~s/^$here_str_marker\s*$//) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$here_str_mode and $l =~ s/^$here_str_marker\s*$//
MC/DC0%0/2
$here_str_mode and $l =~ s/^$here_str_marker\s*$//
$here_str_mode
$l =~ s/^$here_str_marker\s*$//
Truth table33%1/3
A and B
A= $here_str_modeB= $l =~ s/^$here_str_marker\s*$//
| |||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | $here_str_mode = 0; | |||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | ▶ | $self->debug("here string mode off") if $self->{debug_mod} >= 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | ▶ | $self->debug("flushing $block_type block") if $self->{debug_mod} >= 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||
| 334 | 2 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | my $name = "handle_"; | |||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | $name.=$block_type; | |||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | &$name($self, [ @multiline_block ] ); | |||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | undef @multiline_block; undef $block_type; | |||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | next LINE; | |||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||
| 346 | } | ||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||
| 348 | 1 | ▶ | if ( $block_type and $l!~/\\\s*$/ and ! $here_str_mode ){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$block_type and not $l =~ /\\\s*$/ and not $here_str_mode
$block_type and not $l =~ /\\\s*$/
MC/DC0%0/3
$block_type and not $l =~ /\\\s*$/ and not $here_str_mode
$block_type
not $l =~ /\\\s*$/
not $here_str_mode
Truth table25%1/4
A and not(B) and not(C)
A= $block_typeB= not $l =~ /\\\s*$/C= not $here_str_mode
| |||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||
| 350 | 2 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | my $name = "handle_"; | |||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | $name.=$block_type; | |||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | ▶ | $self->debug("flushing $block_type block") if $self->{debug_mod} >= 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | &$name($self, [ @multiline_block ] ); | |||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | undef @multiline_block; undef $block_type; | |||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||
| 365 | 1 | ▶ | if ( $block_type and $l=~/^\s*(code|generator|validator):\s*(.*)/ and ! $here_str_mode ){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$block_type and $l =~ /^\s*(code|generator|validator):\s*(.*)/ and not $here_str_mode
$block_type and $l =~ /^\s*(code|generator|validator):\s*(.*)/
MC/DC0%0/3
$block_type and $l =~ /^\s*(code|generator|validator):\s*(.*)/ and not $here_str_mode
$block_type
$l =~ /^\s*(code|generator|validator):\s*(.*)/
not $here_str_mode
Truth table25%1/4
A and B and not(C)
A= $block_typeB= $l =~ /^\s*(code|generator|validator):\s*(.*)/C= not $here_str_mode
| |||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||
| 367 | 2 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | my $name = "handle_"; | |||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | $name.=$block_type; | |||||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | ▶ | $self->debug("flushing $block_type block") if $self->{debug_mod} >= 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | &$name($self, [ @multiline_block ] ); | |||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | undef @multiline_block; undef $block_type; | |||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||
| 382 | 1 | ▶ | if ( $block_type && ( $l=~s/\\\s*$// or $here_str_mode )) { # multiline block | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition16%1/6
$block_type and $l =~ s/\\\s*$// || $here_str_mode
$l =~ s/\\\s*$// or $here_str_mode
MC/DC0%0/3
$block_type and $l =~ s/\\\s*$// || $here_str_mode
$block_type
$l =~ s/\\\s*$//
$here_str_mode
Truth table25%1/4
A and B or C
A= $block_typeB= $l =~ s/\\\s*$//C= $here_str_mode
| |||||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||
| 384 | # this is multiline block or here string, | ||||||||||||||||||||||||||||||||||||||||||
| 385 | # accumulate lines until meet line not ending with '\' ( for multiline blocks ) | ||||||||||||||||||||||||||||||||||||||||||
| 386 | # or here string end marker ( for here stings ) | ||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | push @multiline_block, $l; | |||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | next LINE; | |||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||
| 396 | 1 | ▶ | if ( $l=~/^\s*begin:\s*$/) { # begining of the text block | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 8 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | ▶ | do { undef @multiline_block; undef $block_type } if $block_type; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | ▶ | die "you can't switch to text block mode when within mode is enabled" if $self->{within_mode}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | $self->{context_modificator} = Outthentic::DSL::Context::TextBlock->new(); | |||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | ▶ | $self->debug('text block start') if $self->{debug_mod} >= 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | $self->{block_mode} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | $self->reset_succeeded(); | |||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||
| 410 | } elsif ($l=~/^\s*end:\s*$/) { # end of the text block | ||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | $self->{block_mode} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | $self->reset_context(); | |||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | ▶ | $self->debug('text block end') if $self->{debug_mod} >= 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||||
| 418 | } elsif ($l=~/^\s*reset_context:\s*$/) { | ||||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | ▶ | do { undef @multiline_block; undef $block_type } if $block_type; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | $self->reset_context(); | |||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||
| 423 | } elsif ($l=~/^\s*assert:\s+(\d+)\s+(.*)/) { | ||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||
| 425 | 0 | my $status = $1; my $message = $2; | |||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | ▶ | do { undef @multiline_block; undef $block_type } if $block_type; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | ▶ | $self->debug("assert found: $status | $message") if $self->{debug_mod} >= 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | ▶ | $status = 0 if $status eq 'false'; # ruby to perl5 conversion | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | ▶ | $status = 1 if $status eq 'true'; # ruby to perl5 conversion | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | $self->add_result({ status => $status , message => $message }); | |||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||
| 437 | } elsif ($l=~/^\s*between:\s+(.*)/) { # range context | ||||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | ▶ | die "you can't switch to range context mode when within mode is enabled" if $self->{within_mode}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | ▶ | die "you can't switch to range context mode when block mode is enabled" if $self->{block_mode}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | my $pattern = $1; | |||||||||||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | ▶ | do { undef @multiline_block; undef $block_type } if $block_type; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | $self->{context_modificator} = Outthentic::DSL::Context::Range->new($1); | |||||||||||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||||||||||
| 450 | } elsif ($l=~/^\s*(code|generator|validator):\s*(.*)/) { | ||||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | my $my_block_type = $1; | |||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | my $code = $2; | |||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | ▶ | if ( $code=~s/(.*)\\\s*$// ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||||||
| 458 | # this is multiline block, accumulate lines until meet '\' line | ||||||||||||||||||||||||||||||||||||||||||
| 459 | 0 | $block_type = $my_block_type; | |||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | my $first_line = $1; | |||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | push @multiline_block, $first_line; | |||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | ▶ | $self->debug("starting $block_type block") if $self->{debug_mod} >= 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | ▶ | $self->debug("first line in block: <<<$first_line>>>") if $self->{debug_mod} >= 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||
| 466 | } elsif ( $code=~s/<<(\S+)// ) { | ||||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||
| 468 | 0 | $block_type = $my_block_type; | |||||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | $here_str_mode = 1; | |||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | $here_str_marker = $1; | |||||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | ▶ | $self->debug("$block_type block start. heredoc marker: $here_str_marker") if $self->{debug_mod} >= 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||
| 477 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | ▶ | $self->debug("one-line $my_block_type found: $code") if $self->{debug_mod} >= 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||||||
| 481 | 2 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | my $name = "handle_"; | |||||||||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | $name.=$my_block_type; | |||||||||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | ▶ | $self->debug("flushing one-line $block_type block") if $self->{debug_mod} >= 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | &$name($self,$code); | |||||||||||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||||||||||||||||
| 492 | } | ||||||||||||||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||||||||||||
| 494 | } elsif ($l=~/^\s*regexp:\s*(.*)/) { # `regexp' line | ||||||||||||||||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||||||||||||||||
| 496 | 0 | my $re = $1; | |||||||||||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | $re=~s/\s+#.*//; | |||||||||||||||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | $re=~s/^\s+//; | |||||||||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | $self->handle_regexp($re); | |||||||||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||||||||||
| 504 | } elsif ($l=~/^\s*within:\s*(.*)/) { | ||||||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | ▶ | die "you can't switch to within mode when text block mode is enabled" if $self->{block_mode}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||||||||||
| 508 | 0 | my $re = $1; | |||||||||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||||||||||
| 510 | 0 | $re=~s/\s+#.*//; | |||||||||||||||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||||||||||||||||
| 512 | 0 | $re=~s/^\s+//; | |||||||||||||||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | $self->handle_within($re); | |||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||
| 516 | } else { # `plain string' line | ||||||||||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||||||||||
| 518 | 1 | $l=~s/\s+#.*//; | |||||||||||||||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||||||||||||||||
| 520 | 1 | $l=~s/^\s+//; | |||||||||||||||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||||||||||||||||
| 522 | 1 | $self->handle_plain($l); | |||||||||||||||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||||||||||||||||
| 524 | } | ||||||||||||||||||||||||||||||||||||||||||
| 525 | } | ||||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||||
| 527 | 1 | ▶ | if ( $block_type ){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||||||||||||||||
| 529 | 2 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | my $name = "handle_"; | |||||||||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | ▶ | $self->debug("flushing $block_type block") if $self->{debug_mod} >= 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||||||||||||||||
| 535 | 0 | $name.=$block_type; | |||||||||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||||||||||
| 537 | 0 | &$name($self, [ @multiline_block ] ); | |||||||||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | undef @multiline_block; undef $block_type; | |||||||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||||||||||||
| 542 | } | ||||||||||||||||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||||||||||||||||
| 544 | } | ||||||||||||||||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||||||||||||||||
| 547 | 0 | ▶ | sub handle_code { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handle_code: not called CC=18 SCAR=58.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||||||||||||||||
| 549 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 550 | 0 | my $code = shift; | |||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | my $results; | |||||||||||||||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||||||||||||||||
| 553 | 0 | ▶ | if (! ref $code) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||||||||||
| 555 | 0 | $results = eval "package main; $code;"; | |||||||||||||||||||||||||||||||||||||||||
| 556 | 0 | ▶ | confess "eval error; sub:handle_code; code:$code\nerror: $@" if $@; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 557 | 0 | ▶ | $self->debug("code OK. single line. code: $code") if $self->{debug_mod} >= 3; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||||||||||||||||
| 559 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||||||||||||||||
| 561 | 0 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||||||||||||||||
| 563 | 0 | my $code_to_print = join "\n", map { my $v=$_; $i++; "[$i] $v" } @$code; | |||||||||||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||||||||||
| 565 | 0 | ▶ | if ($code->[0]=~s/^\!(.*)//) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | my $ext_runner = $1; | |||||||||||||||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | my $language = (split /\\/, $ext_runner)[-1]; | |||||||||||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||||||||||||
| 571 | 0 | ▶ | if ($language eq 'perl') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||||||||||||||||
| 573 | 0 | shift @$code; | |||||||||||||||||||||||||||||||||||||||||
| 574 | 0 | my $code_to_eval = join "\n", @$code; | |||||||||||||||||||||||||||||||||||||||||
| 575 | 0 | $results = eval "package main; $code_to_eval"; | |||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | ▶ | confess "eval error; sub:handle_code; code:\n$code_to_print\nerror: $@" if $@; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 577 | 0 | ▶ | $self->debug("code OK. inline(perl). $code_to_eval") if $self->{debug_mod} >= 3; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||||||||||||||||
| 579 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||||||||||||||||
| 581 | 0 | my $source_file = File::Temp->new( DIR => $self->{cache_dir} , UNLINK => 0 ); | |||||||||||||||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||||||||||||||||
| 583 | 0 | shift @$code; | |||||||||||||||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||||||||||||||||
| 585 | 0 | my $code_to_eval = join "\n", @$code; | |||||||||||||||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||||||||||||||||
| 587 | 0 | ▶ | open SOURCE_CODE, '>', $source_file or die "can't open source code file $source_file to write: $!"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||||||||||||||||
| 589 | 0 | print SOURCE_CODE $code_to_eval; | |||||||||||||||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | close SOURCE_CODE; | |||||||||||||||||||||||||||||||||||||||||
| 592 | |||||||||||||||||||||||||||||||||||||||||||
| 593 | 0 | ▶ | if ($language eq 'bash'){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 594 | |||||||||||||||||||||||||||||||||||||||||||
| 595 | 0 | ▶ | if ($self->{languages}->{$language}){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 596 | 0 | $ext_runner = "bash -c '".($self->{languages}->{$language})." && source $source_file'"; | |||||||||||||||||||||||||||||||||||||||||
| 597 | }else{ | ||||||||||||||||||||||||||||||||||||||||||
| 598 | 0 | $ext_runner = "bash -c 'source $source_file'"; | |||||||||||||||||||||||||||||||||||||||||
| 599 | } | ||||||||||||||||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||||||||||||||||
| 601 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | ▶ | $ext_runner = $self->{languages}->{$language} if $self->{languages}->{$language}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | $ext_runner.=' '.$source_file; | |||||||||||||||||||||||||||||||||||||||||
| 604 | } | ||||||||||||||||||||||||||||||||||||||||||
| 605 | |||||||||||||||||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||||||||||||||||
| 607 | 0 | my $st = system("$ext_runner 2>$source_file.err 1>$source_file.out"); | |||||||||||||||||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||||||||||||||||
| 609 | 0 | ▶ | if ($st != 0){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 610 | 0 | confess "$ext_runner failed, see $source_file.err for details"; | |||||||||||||||||||||||||||||||||||||||||
| 611 | } | ||||||||||||||||||||||||||||||||||||||||||
| 612 | |||||||||||||||||||||||||||||||||||||||||||
| 613 | 0 | ▶ | $self->debug("code OK. inline. $ext_runner") if $self->{debug_mod} >= 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||||||||||||||||
| 615 | 0 | ▶ | open EXT_OUT, "$source_file.out" or die "can't open file $source_file.out to read: $!"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 616 | 0 | $results = join "", <EXT_OUT>; | |||||||||||||||||||||||||||||||||||||||||
| 617 | 0 | close EXT_OUT; | |||||||||||||||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||||||||||||||||
| 619 | 0 | ▶ | unless ($ENV{OTX_KEEP_SOURCE_FILES}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 620 | 0 | unlink("$source_file.out"); | |||||||||||||||||||||||||||||||||||||||||
| 621 | 0 | unlink("$source_file.err"); | |||||||||||||||||||||||||||||||||||||||||
| 622 | 0 | unlink("$source_file"); | |||||||||||||||||||||||||||||||||||||||||
| 623 | } | ||||||||||||||||||||||||||||||||||||||||||
| 624 | } | ||||||||||||||||||||||||||||||||||||||||||
| 625 | |||||||||||||||||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||||||||||||||||
| 627 | |||||||||||||||||||||||||||||||||||||||||||
| 628 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||||||||||||||||
| 630 | 0 | my $code_to_eval = join "\n", @$code; | |||||||||||||||||||||||||||||||||||||||||
| 631 | 0 | $results = eval "package main; $code_to_eval"; | |||||||||||||||||||||||||||||||||||||||||
| 632 | 0 | ▶ | confess "eval error; sub:handle_code; code:\n$code_to_print\nerror: $@" if $@; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 633 | 0 | ▶ | $self->debug("code OK. multiline. $code_to_eval") if $self->{debug_mod} >= 3; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 634 | |||||||||||||||||||||||||||||||||||||||||||
| 635 | } | ||||||||||||||||||||||||||||||||||||||||||
| 636 | |||||||||||||||||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||||||||||||||||
| 638 | } | ||||||||||||||||||||||||||||||||||||||||||
| 639 | |||||||||||||||||||||||||||||||||||||||||||
| 640 | 0 | return $results; | |||||||||||||||||||||||||||||||||||||||||
| 641 | |||||||||||||||||||||||||||||||||||||||||||
| 642 | } | ||||||||||||||||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||||||||||||||||
| 644 | 0 | ▶ | sub handle_validator { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handle_validator: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 645 | |||||||||||||||||||||||||||||||||||||||||||
| 646 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 647 | 0 | my $code = shift; | |||||||||||||||||||||||||||||||||||||||||
| 648 | |||||||||||||||||||||||||||||||||||||||||||
| 649 | 0 | ▶ | if (! defined ($self->{last_check_status}) or $self->{last_check_status}){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $self->{"last_check_status"} or $self->{"last_check_status"}
MC/DC0%0/2
not defined $self->{"last_check_status"} or $self->{"last_check_status"}
not defined $self->{"last_check_status"}
$self->{"last_check_status"}
Truth table0%0/3
not(A) or B
A= not defined $self->{"last_check_status"}B= $self->{"last_check_status"}
| |||||||||||||||||||||||||||||||||||||||||||
| 650 | 0 | my $r = $self->handle_code($code); | |||||||||||||||||||||||||||||||||||||||||
| 651 | 0 | $self->add_result({ status => $r->[0] , message => $r->[1] }); | |||||||||||||||||||||||||||||||||||||||||
| 652 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 653 | 0 | ▶ | $self->debug("skip validator step because last check has been failed") if $self->{debug_mod} >= 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 654 | } | ||||||||||||||||||||||||||||||||||||||||||
| 655 | |||||||||||||||||||||||||||||||||||||||||||
| 656 | |||||||||||||||||||||||||||||||||||||||||||
| 657 | } | ||||||||||||||||||||||||||||||||||||||||||
| 658 | |||||||||||||||||||||||||||||||||||||||||||
| 659 | 0 | ▶ | sub handle_generator { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handle_generator: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 660 | |||||||||||||||||||||||||||||||||||||||||||
| 661 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 662 | 0 | my $code = shift; | |||||||||||||||||||||||||||||||||||||||||
| 663 | |||||||||||||||||||||||||||||||||||||||||||
| 664 | 0 | ▶ | if (! defined ($self->{last_check_status}) or $self->{last_check_status}){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $self->{"last_check_status"} or $self->{"last_check_status"}
MC/DC0%0/2
not defined $self->{"last_check_status"} or $self->{"last_check_status"}
not defined $self->{"last_check_status"}
$self->{"last_check_status"}
Truth table0%0/3
not(A) or B
A= not defined $self->{"last_check_status"}B= $self->{"last_check_status"}
| |||||||||||||||||||||||||||||||||||||||||||
| 665 | 0 | $self->validate( | |||||||||||||||||||||||||||||||||||||||||
| 666 | $self->handle_code($code) | ||||||||||||||||||||||||||||||||||||||||||
| 667 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 668 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 669 | 0 | ▶ | $self->debug("skip generator step because last check has been failed") if $self->{debug_mod} >= 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 670 | } | ||||||||||||||||||||||||||||||||||||||||||
| 671 | |||||||||||||||||||||||||||||||||||||||||||
| 672 | |||||||||||||||||||||||||||||||||||||||||||
| 673 | } | ||||||||||||||||||||||||||||||||||||||||||
| 674 | |||||||||||||||||||||||||||||||||||||||||||
| 675 | 1 | ▶ | sub handle_simple { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handle_simple: called CC=10 SCAR=34.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||||||||||||||||
| 677 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 678 | 1 | my $pattern = shift; | |||||||||||||||||||||||||||||||||||||||||
| 679 | 1 | my $check_type = shift; | |||||||||||||||||||||||||||||||||||||||||
| 680 | |||||||||||||||||||||||||||||||||||||||||||
| 681 | 1 | my $msg; | |||||||||||||||||||||||||||||||||||||||||
| 682 | |||||||||||||||||||||||||||||||||||||||||||
| 683 | 1 | my $lshort = $self->_short_string($pattern); | |||||||||||||||||||||||||||||||||||||||||
| 684 | |||||||||||||||||||||||||||||||||||||||||||
| 685 | 1 | my $reset_context = 0; | |||||||||||||||||||||||||||||||||||||||||
| 686 | |||||||||||||||||||||||||||||||||||||||||||
| 687 | 1 | ▶ | if ($self->{within_mode}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 688 | |||||||||||||||||||||||||||||||||||||||||||
| 689 | 0 | $self->{within_mode} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 690 | |||||||||||||||||||||||||||||||||||||||||||
| 691 | 0 | $reset_context = 1; | |||||||||||||||||||||||||||||||||||||||||
| 692 | |||||||||||||||||||||||||||||||||||||||||||
| 693 | 0 | ▶ | if ($self->{last_check_status}){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 694 | 0 | ▶ | if ($check_type eq 'regexp'){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 695 | 0 | $msg = "'".($self->_short_string($self->{last_match_line}))."' match /$lshort/" | |||||||||||||||||||||||||||||||||||||||||
| 696 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 697 | 0 | $msg = "'".($self->_short_string($self->{last_match_line}))."' has '".$lshort."'" | |||||||||||||||||||||||||||||||||||||||||
| 698 | } | ||||||||||||||||||||||||||||||||||||||||||
| 699 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 700 | 0 | ▶ | if ($check_type eq 'regexp'){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 701 | 0 | $msg = "text match /$lshort/" | |||||||||||||||||||||||||||||||||||||||||
| 702 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 703 | 0 | $msg = "text has '".$lshort."'" | |||||||||||||||||||||||||||||||||||||||||
| 704 | } | ||||||||||||||||||||||||||||||||||||||||||
| 705 | } | ||||||||||||||||||||||||||||||||||||||||||
| 706 | |||||||||||||||||||||||||||||||||||||||||||
| 707 | |||||||||||||||||||||||||||||||||||||||||||
| 708 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 709 | |||||||||||||||||||||||||||||||||||||||||||
| 710 | 1 | ▶ | if ($self->{block_mode}){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 711 | 0 | ▶ | if ($check_type eq 'regexp'){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 712 | 0 | $msg = "[b] text match /$lshort/"; | |||||||||||||||||||||||||||||||||||||||||
| 713 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 714 | 0 | $msg = "[b] text has '".$lshort."'"; | |||||||||||||||||||||||||||||||||||||||||
| 715 | } | ||||||||||||||||||||||||||||||||||||||||||
| 716 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 717 | 1 | ▶ | if ($check_type eq 'regexp'){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 718 | 0 | $msg = "text match /$lshort/"; | |||||||||||||||||||||||||||||||||||||||||
| 719 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 720 | 1 | $msg = "text has '".$lshort."'"; | |||||||||||||||||||||||||||||||||||||||||
| 721 | } | ||||||||||||||||||||||||||||||||||||||||||
| 722 | } | ||||||||||||||||||||||||||||||||||||||||||
| 723 | } | ||||||||||||||||||||||||||||||||||||||||||
| 724 | |||||||||||||||||||||||||||||||||||||||||||
| 725 | |||||||||||||||||||||||||||||||||||||||||||
| 726 | 1 | $self->check_line($pattern,$check_type, $msg); | |||||||||||||||||||||||||||||||||||||||||
| 727 | |||||||||||||||||||||||||||||||||||||||||||
| 728 | 1 | ▶ | $self->reset_context if $reset_context; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 729 | |||||||||||||||||||||||||||||||||||||||||||
| 730 | 1 | ▶ | $self->debug("$check_type check DONE. >>> <<<$pattern>>>") if $self->{debug_mode} >= 3; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 731 | |||||||||||||||||||||||||||||||||||||||||||
| 732 | } | ||||||||||||||||||||||||||||||||||||||||||
| 733 | |||||||||||||||||||||||||||||||||||||||||||
| 734 | 0 | ▶ | sub handle_regexp { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handle_regexp: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 735 | |||||||||||||||||||||||||||||||||||||||||||
| 736 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 737 | 0 | my $re = shift; | |||||||||||||||||||||||||||||||||||||||||
| 738 | |||||||||||||||||||||||||||||||||||||||||||
| 739 | 0 | $self->handle_simple($re, 'regexp'); | |||||||||||||||||||||||||||||||||||||||||
| 740 | |||||||||||||||||||||||||||||||||||||||||||
| 741 | } | ||||||||||||||||||||||||||||||||||||||||||
| 742 | |||||||||||||||||||||||||||||||||||||||||||
| 743 | 0 | ▶ | sub handle_within { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handle_within: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 744 | |||||||||||||||||||||||||||||||||||||||||||
| 745 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 746 | 0 | my $pattern = shift; | |||||||||||||||||||||||||||||||||||||||||
| 747 | |||||||||||||||||||||||||||||||||||||||||||
| 748 | 0 | my $msg; | |||||||||||||||||||||||||||||||||||||||||
| 749 | |||||||||||||||||||||||||||||||||||||||||||
| 750 | 0 | ▶ | if ($self->{within_mode}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 751 | 0 | ▶ | if ($self->{last_check_status}){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 752 | 0 | $msg = "'".($self->_short_string($self->{last_match_line}))."' match /$pattern/" | |||||||||||||||||||||||||||||||||||||||||
| 753 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 754 | 0 | $msg = "text match /$pattern/" | |||||||||||||||||||||||||||||||||||||||||
| 755 | } | ||||||||||||||||||||||||||||||||||||||||||
| 756 | |||||||||||||||||||||||||||||||||||||||||||
| 757 | }else{ | ||||||||||||||||||||||||||||||||||||||||||
| 758 | 0 | $msg = "text match /$pattern/"; | |||||||||||||||||||||||||||||||||||||||||
| 759 | } | ||||||||||||||||||||||||||||||||||||||||||
| 760 | |||||||||||||||||||||||||||||||||||||||||||
| 761 | 0 | $self->{within_mode} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 762 | |||||||||||||||||||||||||||||||||||||||||||
| 763 | 0 | $self->check_line($pattern,'regexp', $msg); | |||||||||||||||||||||||||||||||||||||||||
| 764 | |||||||||||||||||||||||||||||||||||||||||||
| 765 | 0 | ▶ | $self->debug("within check DONE. >>> <<<$pattern>>>") if $self->{debug_mode} >= 3; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 766 | |||||||||||||||||||||||||||||||||||||||||||
| 767 | } | ||||||||||||||||||||||||||||||||||||||||||
| 768 | |||||||||||||||||||||||||||||||||||||||||||
| 769 | 1 | ▶ | sub handle_plain { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handle_plain: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 770 | |||||||||||||||||||||||||||||||||||||||||||
| 771 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 772 | 1 | my $l = shift; | |||||||||||||||||||||||||||||||||||||||||
| 773 | |||||||||||||||||||||||||||||||||||||||||||
| 774 | 1 | $self->handle_simple($l, 'default'); | |||||||||||||||||||||||||||||||||||||||||
| 775 | |||||||||||||||||||||||||||||||||||||||||||
| 776 | } | ||||||||||||||||||||||||||||||||||||||||||
| 777 | |||||||||||||||||||||||||||||||||||||||||||
| 778 | |||||||||||||||||||||||||||||||||||||||||||
| 779 | 1 | ▶ | sub _short_string { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_short_string: called CC=6 SCAR=18.0
| |||||||||||||||||||||||||||||||||||||||||||
| 780 | |||||||||||||||||||||||||||||||||||||||||||
| 781 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 782 | 1 | my $str = shift; | |||||||||||||||||||||||||||||||||||||||||
| 783 | 1 | my $sstr = substr( $str, 0, $self->{match_l} ); | |||||||||||||||||||||||||||||||||||||||||
| 784 | |||||||||||||||||||||||||||||||||||||||||||
| 785 | 1 | s{\r}[]g for $str; | |||||||||||||||||||||||||||||||||||||||||
| 786 | 1 | s{\r}[]g for $sstr; | |||||||||||||||||||||||||||||||||||||||||
| 787 | |||||||||||||||||||||||||||||||||||||||||||
| 788 | 1 | s/\s+$// for $sstr; | |||||||||||||||||||||||||||||||||||||||||
| 789 | 1 | s/\s+$// for $str; | |||||||||||||||||||||||||||||||||||||||||
| 790 | |||||||||||||||||||||||||||||||||||||||||||
| 791 | 1 | ▶ | return $sstr < $str ? "$sstr ..." : $sstr; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 792 | |||||||||||||||||||||||||||||||||||||||||||
| 793 | } | ||||||||||||||||||||||||||||||||||||||||||
| 794 | |||||||||||||||||||||||||||||||||||||||||||
| 795 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 796 | |||||||||||||||||||||||||||||||||||||||||||
| 797 | __END__ | ||||||||||||||||||||||||||||||||||||||||||