lib/TUI/Validate/PXPictureValidator.pm

filter: Statementstmt 13.7% 60 / 435 Branchbran 0.0% 0 / 246 Conditioncond 0.0% 0 / 57 MC/DCmcdc 0.0% 0 / 37 Subroutinesub 28.9% 11 / 38 Podpod 88.8% 8 / 9 totaltotal 9.6% 79 / 822 CC 153 SCAR 57.4
CC
153
Cov
8%
__ANON__
1056.0
__ANON__
420.0
picture
272.0
CRAP 312.4
« lib/TUI/Views/ScrollBar.pm ↑ Summary lib/TUI/Dialogs/Button.pm »
1 package TUI::Validate::PXPictureValidator;
2 # ABSTRACT: Validator for picture-based input validation with auto-fill support
3
4 4 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7
8 4 our $VERSION = '2.000002';
9 4 $VERSION =~ tr/_//d;
10 4 our $AUTHORITY = 'cpan:BRICKPOOL';
11
12 4 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
13 4 our @EXPORT = qw(
14 TPXPictureValidator
15 new_TPXPictureValidator
16 );
17
18 4 ▶use Scalar::Util qw( readonly );
Subroutine BEGIN: called CC=1 SCAR=0.0
19 4 ▶use TUI::toolkit;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 4 ▶use TUI::toolkit::Types qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
21 Maybe
22 :is
23 :types
24 4 );
25
26 4 ▶use TUI::MsgBox::Const qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
27 mfError
28 mfOKButton
29 4 );
30 4 ▶use TUI::MsgBox::MsgBoxText qw( messageBox );
Subroutine BEGIN: called CC=1 SCAR=0.0
31 4 ▶use TUI::Validate::Const qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
32 :TPicResult
33 vsSyntax
34 voFill
35 4 );
36 4 ▶use TUI::Validate::Validator;
Subroutine BEGIN: called CC=1 SCAR=0.0
37
38 sub TPXPictureValidator() { __PACKAGE__ }
39 sub name() { 'TPXPictureValidator' };
40 0 ▶sub new_TPXPictureValidator { __PACKAGE__->from(@_) }
Subroutine new_TPXPictureValidator: not called CC=1 SCAR=6.9
Pod documented
41
42 4 extends TValidator;
43
44 # declare global variables
45 4 our $errorMsg = "Error in picture format.\n %s";
46
47 # private attributes
48 4 has index => ( is => 'bare' );
49 4 has jndex => ( is => 'bare' );
50
51 # protected attributes
52 0 ▶has pic => ( is => 'ro', default => sub { die 'required '} );
Subroutine __ANON__: not called CC=1 SCAR=1.2
53
54 # private methods
55 my (
56 4 $consume,
57 $toGroupEnd,
58 $skipToComma,
59 $calcTerm,
60 $iteration,
61 $group,
62 $checkComplete,
63 $scan,
64 $process,
65 $syntaxCheck,
66 );
67
68 0 ▶sub BUILDARGS { # \%args (%args)
Subroutine BUILDARGS: not called CC=1 SCAR=6.9
Pod documented
69 0 state $sig = signature(
70 method => 1,
71 named => [
72 pic => Str, { alias => 'aPic' },
73 autoFill => Bool,
74 ],
75 caller_level => +1,
76 );
77 0 my ( $class, $args ) = $sig->( @_ );
78 0 return { %$args };
79 }
80
81 0 ▶sub BUILD { # void (\%args)
Subroutine BUILD: not called CC=6 SCAR=37.4
Pod documented
82 0 my ( $self, $args ) = @_;
83 0 ▶ assert ( @_ == 2 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 0 0
84 0 ▶ assert ( is_Object $self );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($self) 0 0 0
85 0 ▶ assert ( is_HashRef $args );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_HashRef($args) 0 0 0
86 $self->{options} |= voFill
87 0 ▶ if ( $args->{autoFill} );
Branch: 1 branch
BranchTrueFalseTotal
if $args->{"autoFill"} 0 0 0
88 0 my $s = '';
89 0 ▶ $self->{status} = vsSyntax
Branch: 1 branch
BranchTrueFalseTotal
if 0 0 0
90 if $self->picture( $s, false ) != prEmpty;
91 0 return;
92 }
93
94 0 ▶sub from { # $obj ($aPic, $autoFill)
Subroutine from: not called CC=1 SCAR=6.9
Pod undocumented
95 0 state $sig = signature(
96 method => 1,
97 pos => [Str, Bool],
98 );
99 0 my ( $class, @args ) = $sig->( @_ );
100 0 return $class->new( pic => $args[0], autoFill => $args[1] );
101 }
102
103 0 ▶sub DEMOLISH { # void ($in_global_destruction)
Subroutine DEMOLISH: not called CC=3 SCAR=24.8
Pod documented
104 0 my ( $self, $in_global_destruction ) = @_;
105 0 ▶ assert ( @_ == 2 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 0 0
106 0 ▶ assert ( is_Object $self );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($self) 0 0 0
107 0 $self->{pic} = undef;
108 0 return;
109 }
110
111 0 ▶sub error { # void ()
Subroutine error: not called CC=1 SCAR=6.9
Pod documented
112 0 state $sig = signature(
113 method => Object,
114 pos => [],
115 );
116 0 my ( $self ) = $sig->( @_ );
117 0 messageBox( mfError | mfOKButton, $errorMsg, $self->{pic} );
118 0 return;
119 }
120
121 0 ▶sub isValidInput { # $bool ($s, $suppressFill)
Subroutine isValidInput: not called CC=4 SCAR=30.0
Pod documented
122 0 state $sig = signature(
123 method => Object,
124 pos => [Str, Bool],
125 );
126 0 my ( $self, $s, $suppressFill ) = $sig->( @_ );
127 0 alias: for $s ( $_[1] ) {
128 0 ▶ my $doFill = ( $self->{options} & voFill ) && !$suppressFill;
Condition0%0/3
$self->{'options'} & 1 && !$suppressFill
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{'options'} & 1 && !$suppressFill
$self->{'options'} & 1 !$suppressFill
Truth table0%0/3
A && not(B)
A= $self->{'options'} & 1B= !$suppressFill
ABresult
0X0
100
111
129 0 ▶ return $self->{pic} eq '' || $self->picture( $s, $doFill ) != prError;
Condition0%0/3
$self->{'pic'} eq '' || $self->picture($s, $doFill) != 3
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{'pic'} eq '' || $self->picture($s, $doFill) != 3
$self->{'pic'} eq '' $self->picture($s, $doFill) != 3
Truth table0%0/3
A || B
A= $self->{'pic'} eq ''B= $self->picture($s, $doFill) != 3
ABresult
1X1
011
000
130 } #/ alias:
131 }
132
133 0 ▶sub isValid { # $bool ($s)
Subroutine isValid: not called CC=2 SCAR=17.9
Pod documented
134 0 state $sig = signature(
135 method => Object,
136 pos => [Str],
137 );
138 0 my ( $self, $s ) = $sig->( @_ );
139 0 ▶ return $self->{pic} eq '' || $self->picture( $s, false ) == prComplete;
Condition0%0/3
$self->{'pic'} eq '' || $self->picture($s, !1) == 0
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{'pic'} eq '' || $self->picture($s, !1) == 0
$self->{'pic'} eq '' $self->picture($s, !1) == 0
Truth table0%0/3
A || B
A= $self->{'pic'} eq ''B= $self->picture($s, !1) == 0
ABresult
1X1
011
000
140 }
141
142 0 ▶my $toUpper = sub { length( uc( $_[0] ) ) == 1 ? uc( $_[0] ) : $_[0] };
Subroutine __ANON__: not called CC=2 SCAR=13.0
Branch: 1 branch
BranchTrueFalseTotal
length uc $_[0] == 1 ? : 0 0 0
143 0 ▶my $isNumber = sub { $_[0] =~ /^\d$/ };
Subroutine __ANON__: not called CC=1 SCAR=1.2
144 0 ▶my $isLetter = sub { $_[0] =~ /^[[:alpha:]]$/ };
Subroutine __ANON__: not called CC=1 SCAR=1.2
145 0 ▶my $isSpecial = sub { length $_[0] == 1 && index( $_[1], $_[0] ) != -1 };
Subroutine __ANON__: not called CC=2 SCAR=13.0
Branch: 1 branch
BranchTrueFalseTotal
length $_[0] == 1 and index($_[1], $_[0]) != -1 0 0 0
146 0 ▶my $numChar = sub { return () = ( $_[1] =~ /\Q$_[0]\E/g ) };
Subroutine __ANON__: not called CC=1 SCAR=1.2
147 0 ▶my $isComplete = sub { $_[0] == prComplete || $_[0] == prAmbiguous };
Subroutine __ANON__: not called CC=2 SCAR=13.0
Branch: 1 branch
BranchTrueFalseTotal
$_[0] == 0 or $_[0] == 5 0 0 0
148 0 ▶my $isIncomplete = sub { $_[0] == prIncomplete || $_[0] == prIncompNoFill };
Subroutine __ANON__: not called CC=2 SCAR=13.0
Branch: 1 branch
BranchTrueFalseTotal
$_[0] == 1 or $_[0] == 6 0 0 0
149
150 0 ▶sub picture { # $picResult ($input, $autoFill)
Subroutine picture: not called CC=16 SCAR=56.1
Pod documented
151 0 state $sig = signature(
152 method => Object,
153 pos => [Maybe[Str], Bool],
154 );
155 0 my ( $self, $input, $autoFill ) = $sig->( @_ );
156 0 alias: for $input ( $_[1] ) {
157
158 0 my $reprocess;
159 my $rslt;
160
161 0 ▶ if ( !$self->$syntaxCheck() ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->$syntaxCheck) 0 0 0
162 0 return prSyntax;
163 }
164
165 0 ▶ if ( !defined( $input ) || !length( $input ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $input and length $input) 0 0 0
Condition0%0/3
defined $input and length $input
!ll&&!rl&&r
000
MC/DC0%0/2
defined $input and length $input
defined $input length $input
Truth table0%0/3
A and B
A= defined $inputB= length $input
ABresult
0X0
100
111
166 0 return prEmpty;
167 }
168
169 0 $self->{jndex} = 0;
170 0 $self->{index} = 0;
171
172 0 $rslt = $self->$process( $input, length( $self->{pic} ) );
173
174 0 ▶ if ( $rslt != prError && $self->{jndex} < length( $input ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rslt != 3 and $self->{"jndex"} < length $input) 0 0 0
Condition0%0/3
$rslt != 3 and $self->{"jndex"} < length $input
!ll&&!rl&&r
000
MC/DC0%0/2
$rslt != 3 and $self->{"jndex"} < length $input
$rslt != 3 $self->{"jndex"} < length $input
Truth table0%0/3
A and B
A= $rslt != 3B= $self->{"jndex"} < length $input
ABresult
0X0
100
111
175 0 $rslt = prError;
176 }
177
178 0 ▶ if ( ( $rslt == prIncomplete ) && $autoFill ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rslt == 1 and $autoFill) 0 0 0
Condition0%0/3
$rslt == 1 and $autoFill
!ll&&!rl&&r
000
MC/DC0%0/2
$rslt == 1 and $autoFill
$rslt == 1 $autoFill
Truth table0%0/3
A and B
A= $rslt == 1B= $autoFill
ABresult
0X0
100
111
179 0 $reprocess = false;
180
181 0 ▶ while ( ( $self->{index} < length( $self->{pic} ) )
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"index"} < length $self->{"pic"} and not &$isSpecial(substr($self->{"pic"}, $self->{"index"}, 1), "#?&!\@*{}[],")) 0 0 0
Condition0%0/3
$self->{"index"} < length $self->{"pic"} and not &$isSpecial(substr($self->{"pic"}, $self->{"index"}, 1), "#?&!\@*{}[],")
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"index"} < length $self->{"pic"} and not &$isSpecial(substr($self->{"pic"}, $self->{"index"}, 1), "#?&!\@*{}[],")
$self->{"index"} < length $self->{"pic"} not &$isSpecial(substr($self->{"pic"}, $self->{"index"}, 1), "#?&!\@*{}[],")
Truth table0%0/3
A and not(B)
A= $self->{"index"} < length $self->{"pic"}B= not &$isSpecial(substr($self->{"pic"}, $self->{"index"}, 1), "#?&!\@*{}[],")
ABresult
0X0
100
111
182 && !&$isSpecial( substr($self->{pic}, $self->{index}, 1), "#?&!@*{}[]," )
183 ) {
184 0 my $pchar = substr( $self->{pic}, $self->{index}, 1 );
185 0 ▶ if ( $pchar eq ';' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pchar eq ";") 0 0 0
186 0 $self->{index}++;
187 0 ▶ last if $self->{index} >= length( $self->{pic} );
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"index"} >= length $self->{"pic"} 0 0 0
188 0 $pchar = substr( $self->{pic}, $self->{index}, 1 );
189 }
190
191 0 $input .= $pchar;
192 0 $self->{index}++;
193 0 $reprocess = true;
194 }
195
196 0 $self->{jndex} = 0;
197 0 $self->{index} = 0;
198 0 ▶ if ( $reprocess ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($reprocess) 0 0 0
199 0 $rslt = $self->$process( $input, length( $self->{pic} ) );
200 }
201 } #/ if ( ( $rslt == prIncomplete...))
202
203 0 ▶ if ( $rslt == prAmbiguous ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($rslt == 5) { } 0 0 0
elsif ($rslt == 6) { } 0 0 0
204 0 return prComplete;
205 }
206 elsif ( $rslt == prIncompNoFill ) {
207 0 return prIncomplete;
208 }
209 else {
210 0 return $rslt;
211 }
212 } #/ alias:
213 }; #/ $picture = sub
214
215 # Consume input
216 0 ▶$consume = sub { # void ($ch, $input)
Subroutine __ANON__: not called CC=7 SCAR=40.3
217 0 my ( $self, $ch, $input ) = @_;
218 0 ▶ assert ( @_ == 3 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 3 0 0 0
219 0 ▶ assert ( is_Object $self );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($self) 0 0 0
220 0 ▶ assert ( is_Str $ch );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Str($ch) 0 0 0
221 0 ▶ assert ( is_Str $input );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Str($input) 0 0 0
222 0 alias: for $input ( $_[2] ) {
223 0 ▶ assert ( !readonly $input );
Branch: 1 branch
BranchTrueFalseTotal
if &readonly($input) 0 0 0
224
225 0 substr( $input, $self->{jndex}, 1 ) = $ch;
226 0 $self->{index}++;
227 0 $self->{jndex}++;
228 0 return;
229
230 } #/ alias:
231 4 };
232
233 # Skip a character or a picture group
234 0 ▶$toGroupEnd = sub { # void (\$i, $termCh)
Subroutine __ANON__: not called CC=14 SCAR=53.5
235 0 my ( $self, $i, $termCh ) = @_;
236 0 ▶ assert ( @_ == 3 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 3 0 0 0
237 0 ▶ assert ( is_Object $self );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($self) 0 0 0
238 0 ▶ assert ( is_ScalarRef $i );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_ScalarRef($i) 0 0 0
239 0 ▶ assert ( is_Int $termCh );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Int($termCh) 0 0 0
240
241 0 my $brkLevel = 0;
242 0 my $brcLevel = 0;
243 0 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
$brkLevel == 0 and $brcLevel == 0 or do { do { return if $$i == $termCh; SWITCH: foreach $_ (substr $self->{"pic"}, $$i, 1) { $_ eq "[" and do { ++$brkLevel; last }; $_ eq "]" and do { --$brkLevel; last }; $_ eq "{" and do { ++$brcLevel; last }; $_ eq "}" and do { --$brcLevel; last }; $_ eq ";" and do { ++$$i; last }; } ; ++$$i } } 0 0 0
Condition0%0/3
$brkLevel == 0 and $brcLevel == 0
!ll&&!rl&&r
000
MC/DC0%0/2
$brkLevel == 0 and $brcLevel == 0
$brkLevel == 0 $brcLevel == 0
Truth table0%0/3
A and B
A= $brkLevel == 0B= $brcLevel == 0
ABresult
0X0
100
111
244 0 ▶ return if $$i == $termCh;
Branch: 1 branch
BranchTrueFalseTotal
if $$i == $termCh 0 0 0
245 0 SWITCH: for ( substr( $self->{pic}, $$i, 1 ) ) {
246 0 ▶ $_ eq '[' and do { $brkLevel++; last };
Branch: 1 branch
BranchTrueFalseTotal
$_ eq "[" and do { ++$brkLevel; last } 0 0 0
247 0 ▶ $_ eq ']' and do { $brkLevel--; last };
Branch: 1 branch
BranchTrueFalseTotal
$_ eq "]" and do { --$brkLevel; last } 0 0 0
248 0 ▶ $_ eq '{' and do { $brcLevel++; last };
Branch: 1 branch
BranchTrueFalseTotal
$_ eq "{" and do { ++$brcLevel; last } 0 0 0
249 0 ▶ $_ eq '}' and do { $brcLevel--; last };
Branch: 1 branch
BranchTrueFalseTotal
$_ eq "}" and do { --$brcLevel; last } 0 0 0
250 0 ▶ $_ eq ';' and do { $$i++; last };
Branch: 1 branch
BranchTrueFalseTotal
$_ eq ";" and do { ++$$i; last } 0 0 0
251 }
252 0 $$i++;
253 } while ( !( $brkLevel == 0 && $brcLevel == 0 ) );
254 0 return;
255 4 }; #/ $toGroupEnd = sub
256
257 # Find a comma separator
258 0 ▶$skipToComma = sub { # $bool ($termCh)
Subroutine __ANON__: not called CC=7 SCAR=40.3
259 0 my ( $self, $termCh ) = @_;
260 0 ▶ assert ( @_ == 2 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 0 0
261 0 ▶ assert ( is_Object $self );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($self) 0 0 0
262 0 ▶ assert ( is_Int $termCh );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Int($termCh) 0 0 0
263 do {
264 0 $self->$toGroupEnd( \$self->{index}, $termCh );
265 } while ( !( $self->{index} == $termCh
266 0 ▶ || substr( $self->{pic}, $self->{index}, 1 ) eq ',' ) );
Branch: 1 branch
BranchTrueFalseTotal
($self->{"index"} == $termCh or substr($self->{"pic"}, $self->{"index"}, 1) eq ",") or do { do { $self->$toGroupEnd(\$self->{"index"}, $termCh) } } 0 0 0
Condition0%0/3
$self->{"index"} == $termCh or substr($self->{"pic"}, $self->{"index"}, 1) eq ","
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"index"} == $termCh or substr($self->{"pic"}, $self->{"index"}, 1) eq ","
$self->{"index"} == $termCh substr($self->{"pic"}, $self->{"index"}, 1) eq ","
Truth table0%0/3
A or B
A= $self->{"index"} == $termChB= substr($self->{"pic"}, $self->{"index"}, 1) eq ","
ABresult
1X1
011
000
267
268 $self->{index}++
269 0 ▶ if substr( $self->{pic}, $self->{index}, 1 ) eq ',';
Branch: 1 branch
BranchTrueFalseTotal
if substr($self->{"pic"}, $self->{"index"}, 1) eq "," 0 0 0
270 0 return $self->{index} < $termCh;
271 4 };
272
273 # Calculate the end of a group
274 0 ▶$calcTerm = sub { # $int ($termCh)
Subroutine __ANON__: not called CC=4 SCAR=30.0
275 0 my ( $self, $termCh ) = @_;
276 0 ▶ assert ( @_ == 2 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 0 0
277 0 ▶ assert ( is_Object $self );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($self) 0 0 0
278 0 ▶ assert ( is_Int $termCh );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Int($termCh) 0 0 0
279 0 my $k = $self->{index};
280 0 $self->$toGroupEnd( \$k, $termCh );
281 0 return $k;
282 4 };
283
284 # The next group is repeated X times
285 0 ▶$iteration = sub { # $picResult ($input, $inTerm)
Subroutine __ANON__: not called CC=15 SCAR=54.8
286 0 my ( $self, $input, $inTerm ) = @_;
287 0 ▶ assert ( @_ == 3 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 3 0 0 0
288 0 ▶ assert ( is_Object $self );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($self) 0 0 0
289 0 ▶ assert ( is_Str $input );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Str($input) 0 0 0
290 0 ▶ assert ( is_Int $inTerm );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Int($inTerm) 0 0 0
291 0 for $input ( $_[1] ) {
292 0 ▶ assert ( !readonly $input );
Branch: 1 branch
BranchTrueFalseTotal
if &readonly($input) 0 0 0
293
294 0 my $itr = 0;
295 0 my $rslt = prError;
296 0 my $termCh;
297
298 0 $self->{index}++; # Skip '*'
299
300 # Retrieve number
301 0 ▶ while ( &$isNumber( substr( $self->{pic}, $self->{index}, 1 ) ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (&$isNumber(substr($self->{"pic"}, $self->{"index"}, 1))) 0 0 0
302 0 my $digit = substr( $self->{pic}, $self->{index}, 1 );
303 0 $itr = $itr * 10 + ( ord( $digit ) - ord( '0' ) );
304 0 $self->{index}++;
305 }
306
307 0 my $k = $self->{index};
308 0 $termCh = $self->$calcTerm( $inTerm );
309
310 # If $itr is 0 allow any number, otherwise enforce the number
311 0 ▶ if ( $itr != 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($itr != 0) { } 0 0 0
312 0 ▶ for ( my $l = 1 ; $l <= $itr ; $l++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($l <= $itr) 0 0 0
313 0 $self->{index} = $k;
314 0 $rslt = $self->$process( $input, $termCh );
315
316 0 ▶ if ( !&$isComplete( $rslt ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (&$isComplete($rslt)) 0 0 0
317
318 # Empty means incomplete since all are required
319 0 ▶ if ( $rslt == prEmpty ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rslt == 2) 0 0 0
320 0 $rslt = prIncomplete;
321 }
322 0 return $rslt;
323 }
324 }
325 }
326 else {
327 0 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
$rslt == 0 and do { do { $self->{"index"} = $k; $rslt = $self->$process($input, $termCh) } } 0 0 0
328 0 $self->{index} = $k;
329 0 $rslt = $self->$process( $input, $termCh );
330 } while ( $rslt == prComplete );
331
332 0 ▶ if ( $rslt == prEmpty || $rslt == prError ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rslt == 2 or $rslt == 3) 0 0 0
Condition0%0/3
$rslt == 2 or $rslt == 3
l!l&&r!l&&!r
000
MC/DC0%0/2
$rslt == 2 or $rslt == 3
$rslt == 2 $rslt == 3
Truth table0%0/3
A or B
A= $rslt == 2B= $rslt == 3
ABresult
1X1
011
000
333 0 $self->{index}++;
334 0 $rslt = prAmbiguous;
335 }
336 }
337
338 0 $self->{index} = $termCh;
339 0 return $rslt;
340 } #/ alias:
341 4 }; #/ $iteration = sub
342
343 # Process a picture group
344 0 ▶$group = sub { # $picResult ($input, $inTerm)
Subroutine __ANON__: not called CC=8 SCAR=42.8
345 0 my ( $self, $input, $inTerm ) = @_;
346 0 ▶ assert ( @_ == 3 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 3 0 0 0
347 0 ▶ assert ( is_Object $self );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($self) 0 0 0
348 0 ▶ assert ( is_Str $input );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Str($input) 0 0 0
349 0 ▶ assert ( is_Int $inTerm );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Int($inTerm) 0 0 0
350 0 alias: for $input ( $_[1] ) {
351 0 ▶ assert ( !readonly $input );
Branch: 1 branch
BranchTrueFalseTotal
if &readonly($input) 0 0 0
352
353 0 my $rslt;
354 my $termCh;
355
356 0 $termCh = $self->$calcTerm( $inTerm );
357 0 $self->{index}++;
358 0 $rslt = $self->$process( $input, $termCh - 1 );
359
360 0 ▶ if ( !&$isIncomplete( $rslt ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (&$isIncomplete($rslt)) 0 0 0
361 0 $self->{index} = $termCh;
362 }
363
364 0 return $rslt;
365 } #/ alias:
366 4 };
367
368 0 ▶$checkComplete = sub { # $picResult ($rslt, $termCh)
Subroutine __ANON__: not called CC=11 SCAR=48.8
369 0 my ( $self, $rslt, $termCh ) = @_;
370 0 ▶ assert ( @_ == 3 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 3 0 0 0
371 0 ▶ assert ( is_Object $self );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($self) 0 0 0
372 0 ▶ assert ( is_PositiveOrZeroInt $rslt );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_PositiveOrZeroInt($rslt) 0 0 0
373 0 ▶ assert ( is_Int $termCh );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Int($termCh) 0 0 0
374
375 0 my $j = $self->{index};
376 0 my $status = true;
377
378 0 ▶ if ( &$isIncomplete( $rslt ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (&$isIncomplete($rslt)) 0 0 0
379
380 # Skip optional pieces
381 0 ▶ while ( $status ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($status) 0 0 0
382 0 my $ch = substr( $self->{pic}, $j, 1 );
383
384 0 ▶ if ( $ch eq '[' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($ch eq '[') { } 0 0 0
elsif ($ch eq '*') { } 0 0 0
385 0 $self->$toGroupEnd( \$j, $termCh );
386 }
387 elsif ( $ch eq '*' ) {
388 0 ▶ if ( !&$isNumber( substr( $self->{pic}, $j + 1, 1 ) ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (&$isNumber(substr($self->{"pic"}, $j + 1, 1))) 0 0 0
389 0 $j++;
390 }
391 0 $self->$toGroupEnd( \$j, $termCh );
392 }
393 else {
394 0 $status = false;
395 }
396 }
397
398 0 ▶ if ( $j == $termCh ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($j == $termCh) 0 0 0
399 0 $rslt = prAmbiguous;
400 }
401 } #/ if ( $self->isIncomplete...)
402
403 0 return $rslt;
404 4 }; #/ $checkComplete = sub
405
406 0 ▶$scan = sub { # $picResult ($input, $termCh)
Subroutine __ANON__: not called CC=32 SCAR=69.6
407 0 my ( $self, $input, $termCh ) = @_;
408 0 ▶ assert ( @_ == 3 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 3 0 0 0
409 0 ▶ assert ( is_Object $self );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($self) 0 0 0
410 0 ▶ assert ( is_Str $input );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Str($input) 0 0 0
411 0 ▶ assert ( is_Int $termCh );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Int($termCh) 0 0 0
412 0 alias: for $input ( $_[1] ) {
413 0 ▶ assert ( !readonly $input );
Branch: 1 branch
BranchTrueFalseTotal
if &readonly($input) 0 0 0
414
415 0 my $ch;
416 0 my ( $rslt, $rScan );
417
418 0 $rScan = prError;
419 0 $rslt = prEmpty;
420
421 0 ▶ while ( ( $self->{index} != $termCh )
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"index"} != $termCh and substr($self->{"pic"}, $self->{"index"}, 1) ne ",") 0 0 0
Condition0%0/3
$self->{"index"} != $termCh and substr($self->{"pic"}, $self->{"index"}, 1) ne ","
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"index"} != $termCh and substr($self->{"pic"}, $self->{"index"}, 1) ne ","
$self->{"index"} != $termCh substr($self->{"pic"}, $self->{"index"}, 1) ne ","
Truth table0%0/3
A and B
A= $self->{"index"} != $termChB= substr($self->{"pic"}, $self->{"index"}, 1) ne ","
ABresult
0X0
100
111
422 && ( substr( $self->{pic}, $self->{index}, 1 ) ne ',' ) )
423 {
424 0 ▶ if ( $self->{jndex} >= length( $input ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"jndex"} >= length $input) 0 0 0
425 0 return $self->$checkComplete( $rslt, $termCh );
426 }
427
428 0 $ch = substr( $input, $self->{jndex}, 1 );
429
430 0 SWITCH: for ( substr( $self->{pic}, $self->{index}, 1 ) ) {
431
432 0 ▶ $_ eq '#' and do {
Branch: 1 branch
BranchTrueFalseTotal
$_ eq "#" and do { if (not &$isNumber($ch)) { return 3; } else { $self->$consume($ch, $input); } ; last } 0 0 0
433 0 ▶ if ( !&$isNumber( $ch ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not &$isNumber($ch)) { } 0 0 0
434 0 return prError();
435 }
436 else {
437 0 $self->$consume( $ch, $input );
438 }
439 0 last;
440 };
441
442 0 ▶ $_ eq '?' and do {
Branch: 1 branch
BranchTrueFalseTotal
$_ eq "?" and do { if (not &$isLetter($ch)) { return 3; } else { $self->$consume($ch, $input); } ; last } 0 0 0
443 0 ▶ if ( !&$isLetter( $ch ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not &$isLetter($ch)) { } 0 0 0
444 0 return prError;
445 }
446 else {
447 0 $self->$consume( $ch, $input );
448 }
449 0 last;
450 };
451
452 0 ▶ $_ eq '&' and do {
Branch: 1 branch
BranchTrueFalseTotal
$_ eq "&" and do { if (not &$isLetter($ch)) { return 3; } else { $self->$consume(&$toUpper($ch), $input); } ; last } 0 0 0
453 0 ▶ if ( !&$isLetter( $ch ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not &$isLetter($ch)) { } 0 0 0
454 0 return prError();
455 }
456 else {
457 0 $self->$consume( &$toUpper( $ch ), $input );
458 }
459 0 last;
460 };
461
462 0 ▶ $_ eq '!' and do {
Branch: 1 branch
BranchTrueFalseTotal
$_ eq "!" and do { $self->$consume(&$toUpper($ch), $input); last } 0 0 0
463 0 $self->$consume( &$toUpper( $ch ), $input );
464 0 last;
465 };
466
467 0 ▶ $_ eq '@' and do {
Branch: 1 branch
BranchTrueFalseTotal
$_ eq "\@" and do { $self->$consume($ch, $input); last } 0 0 0
468 0 $self->$consume( $ch, $input );
469 0 last;
470 };
471
472 0 ▶ $_ eq '*' and do {
Branch: 1 branch
BranchTrueFalseTotal
$_ eq "*" and do { $rslt = $self->$iteration($input, $termCh); unless (&$isComplete($rslt)) { return $rslt; } ; if ($rslt == 3) { $rslt = 5; } ; last } 0 0 0
473 0 $rslt = $self->$iteration( $input, $termCh );
474 0 ▶ if ( !&$isComplete( $rslt ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (&$isComplete($rslt)) 0 0 0
475 0 return $rslt;
476 }
477
478 0 ▶ if ( $rslt == prError ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rslt == 3) 0 0 0
479 0 $rslt = prAmbiguous;
480 }
481 0 last;
482 };
483
484 0 ▶ $_ eq '{' and do {
Branch: 1 branch
BranchTrueFalseTotal
$_ eq "{" and do { $rslt = $self->$group($input, $termCh); unless (&$isComplete($rslt)) { return $rslt; } ; last } 0 0 0
485 0 $rslt = $self->$group( $input, $termCh );
486 0 ▶ if ( !&$isComplete( $rslt ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (&$isComplete($rslt)) 0 0 0
487 0 return $rslt;
488 }
489 0 last;
490 };
491
492 0 ▶ $_ eq '[' and do {
Branch: 1 branch
BranchTrueFalseTotal
$_ eq "[" and do { $rslt = $self->$group($input, $termCh); if (&$isIncomplete($rslt)) { return $rslt; } ; if ($rslt == 3) { $rslt = 5; } ; last } 0 0 0
493 0 $rslt = $self->$group( $input, $termCh );
494 0 ▶ if ( &$isIncomplete( $rslt ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (&$isIncomplete($rslt)) 0 0 0
495 0 return $rslt;
496 }
497 0 ▶ if ( $rslt == prError ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rslt == 3) 0 0 0
498 0 $rslt = prAmbiguous;
499 }
500 0 last;
501 };
502
503 DEFAULT: {
504 0 my $p = substr( $self->{pic}, $self->{index}, 1 );
505
506 0 ▶ if ( $p eq ';' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p eq ";") 0 0 0
507 0 $self->{index}++;
508 0 $p = substr( $self->{pic}, $self->{index}, 1 );
509 }
510
511 0 ▶ if ( &$toUpper( $p ) ne &$toUpper( $ch ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (&$toUpper($p) ne &$toUpper($ch)) 0 0 0
512 0 ▶ if ( $ch ne ' ' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ch ne " ") 0 0 0
513 0 return $rScan;
514 }
515 }
516
517 0 $self->$consume( $p, $input );
518 }
519 } #/ SWITCH: for ( substr( $self->{pic...}))
520
521 0 ▶ if ( $rslt == prAmbiguous ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rslt == 5) { } 0 0 0
522 0 $rslt = prIncompNoFill;
523 }
524 else {
525 0 $rslt = prIncomplete;
526 }
527 } #/ while ( ( $self->{index} ...))
528
529 0 ▶ if ( $rslt == prIncompNoFill ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rslt == 6) { } 0 0 0
530 0 return prAmbiguous;
531 }
532 else {
533 0 return prComplete;
534 }
535 } #/ alias:
536 4 }; #/ $scan = sub
537
538 0 ▶$process = sub { # $picResult ($input, $termCh)
Subroutine __ANON__: not called CC=20 SCAR=60.4
539 0 my ( $self, $input, $termCh ) = @_;
540 0 ▶ assert ( @_ == 3 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 3 0 0 0
541 0 ▶ assert ( is_Object $self );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($self) 0 0 0
542 0 ▶ assert ( is_Str $input );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Str($input) 0 0 0
543 0 ▶ assert ( is_Int $termCh );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Int($termCh) 0 0 0
544 0 alias: for $input ( $_[1] ) {
545 0 ▶ assert ( !readonly $input );
Branch: 1 branch
BranchTrueFalseTotal
if &readonly($input) 0 0 0
546
547 0 my ( $rslt, $rProcess );
548 0 my $incomp;
549 0 my ( $oldI, $oldJ, $incompJ, $incompI );
550
551 0 $incomp = false;
552 0 $oldI = $self->{index};
553 0 $oldJ = $self->{jndex};
554 0 $incompJ = 0;
555
556 0 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
$rslt == 3 || $rslt == 1 and 0 0 0
Condition0%0/3
$rslt == 3 or $rslt == 1
l!l&&r!l&&!r
000
MC/DC0%0/2
$rslt == 3 or $rslt == 1
$rslt == 3 $rslt == 1
Truth table0%0/3
A or B
A= $rslt == 3B= $rslt == 1
ABresult
1X1
011
000
557 0 $rslt = $self->$scan( $input, $termCh );
558
559 # Only accept completes if they make it farther in the input stream
560 # from the last incomplete
561 0 ▶ if ( $rslt == prComplete && $incomp && $self->{jndex} < $incompJ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rslt == 0 and $incomp and $self->{"jndex"} < $incompJ) 0 0 0
Condition0%0/6
$rslt == 0 and $incomp and $self->{"jndex"} < $incompJ
!ll&&!rl&&r
000
$rslt == 0 and $incomp
!ll&&!rl&&r
000
MC/DC0%0/3
$rslt == 0 and $incomp and $self->{"jndex"} < $incompJ
$rslt == 0 $incomp $self->{"jndex"} < $incompJ
Truth table0%0/4
A and B and C
A= $rslt == 0B= $incompC= $self->{"jndex"} < $incompJ
ABCresult
0XX0
10X0
1100
1111
562 0 $rslt = prIncomplete;
563 0 $self->{jndex} = $incompJ;
564 }
565
566 0 ▶ if ( $rslt == prError || $rslt == prIncomplete ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rslt == 3 or $rslt == 1) 0 0 0
Condition0%0/3
$rslt == 3 or $rslt == 1
l!l&&r!l&&!r
000
MC/DC0%0/2
$rslt == 3 or $rslt == 1
$rslt == 3 $rslt == 1
Truth table0%0/3
A or B
A= $rslt == 3B= $rslt == 1
ABresult
1X1
011
000
567 0 $rProcess = $rslt;
568
569 0 ▶ if ( !$incomp && $rslt == prIncomplete ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $incomp and $rslt == 1) 0 0 0
Condition0%0/3
not $incomp and $rslt == 1
!ll&&!rl&&r
000
MC/DC0%0/2
not $incomp and $rslt == 1
not $incomp $rslt == 1
Truth table0%0/3
not(A) and B
A= not $incompB= $rslt == 1
ABresult
0X0
100
111
570 0 $incomp = true;
571 0 $incompI = $self->{index};
572 0 $incompJ = $self->{jndex};
573 }
574
575 0 $self->{index} = $oldI;
576 0 $self->{jndex} = $oldJ;
577
578 0 ▶ if ( !$self->$skipToComma( $termCh ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->$skipToComma($termCh)) 0 0 0
579 0 ▶ if ( $incomp ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($incomp) 0 0 0
580 0 $rProcess = prIncomplete;
581 0 $self->{index} = $incompI;
582 0 $self->{jndex} = $incompJ;
583 }
584 0 return $rProcess;
585 }
586
587 0 $oldI = $self->{index};
588 } #/ if ( ( $rslt == prError...))
589
590 } while ( $rslt == prError || $rslt == prIncomplete );
591
592 0 ▶ if ( $rslt == prComplete && $incomp ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rslt == 0 and $incomp) { } 0 0 0
Condition0%0/3
$rslt == 0 and $incomp
!ll&&!rl&&r
000
MC/DC0%0/2
$rslt == 0 and $incomp
$rslt == 0 $incomp
Truth table0%0/3
A and B
A= $rslt == 0B= $incomp
ABresult
0X0
100
111
593 0 return prAmbiguous;
594 }
595 else {
596 0 return $rslt;
597 }
598 } #/ alias:
599 4 }; #/ $process = sub
600
601 0 ▶$syntaxCheck = sub { # $bool ()
Subroutine __ANON__: not called CC=14 SCAR=53.5
602 0 my ( $self ) = @_;
603 0 ▶ assert ( @_ == 1 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 1 0 0 0
604 0 ▶ assert ( is_Object $self );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($self) 0 0 0
605
606 0 ▶ if ( !defined $self->{pic} || length( $self->{pic} ) == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $self->{"pic"} or length $self->{"pic"} == 0) 0 0 0
Condition0%0/3
not defined $self->{"pic"} or length $self->{"pic"} == 0
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $self->{"pic"} or length $self->{"pic"} == 0
not defined $self->{"pic"} length $self->{"pic"} == 0
Truth table0%0/3
not(A) or B
A= not defined $self->{"pic"}B= length $self->{"pic"} == 0
ABresult
1X1
011
000
607 0 return false;
608 }
609
610 0 ▶ if ( substr( $self->{pic}, -1, 1 ) eq ';' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (substr($self->{"pic"}, -1, 1) eq ";") 0 0 0
611 0 return false;
612 }
613
614 0 my $i = 0;
615 0 my $brkLevel = 0;
616 0 my $brcLevel = 0;
617
618 0 my $len = length( $self->{pic} );
619 0 ▶ while ( $i < $len ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $len) 0 0 0
620 0 SWITCH: for ( substr( $self->{pic}, $i, 1 ) ) {
621 0 ▶ $_ eq '[' and do { $brkLevel++; last };
Branch: 1 branch
BranchTrueFalseTotal
$_ eq "[" and do { ++$brkLevel; last } 0 0 0
622 0 ▶ $_ eq ']' and do { $brkLevel--; last };
Branch: 1 branch
BranchTrueFalseTotal
$_ eq "]" and do { --$brkLevel; last } 0 0 0
623 0 ▶ $_ eq '{' and do { $brcLevel++; last };
Branch: 1 branch
BranchTrueFalseTotal
$_ eq "{" and do { ++$brcLevel; last } 0 0 0
624 0 ▶ $_ eq '}' and do { $brcLevel--; last };
Branch: 1 branch
BranchTrueFalseTotal
$_ eq "}" and do { --$brcLevel; last } 0 0 0
625 0 ▶ $_ eq ';' and do { $i++; last };
Branch: 1 branch
BranchTrueFalseTotal
$_ eq ";" and do { ++$i; last } 0 0 0
626 }
627 0 $i++;
628 }
629
630 0 ▶ return $brkLevel == 0 && $brcLevel == 0;
Condition0%0/3
$brkLevel == 0 && $brcLevel == 0
!ll&&!rl&&r
000
MC/DC0%0/2
$brkLevel == 0 && $brcLevel == 0
$brkLevel == 0 $brcLevel == 0
Truth table0%0/3
A && B
A= $brkLevel == 0B= $brcLevel == 0
ABresult
0X0
100
111
631 4 }; #/ $syntaxCheck = sub
632
633 4 1
634
635 __END__
« lib/TUI/Views/ScrollBar.pm ↑ Summary lib/TUI/Dialogs/Button.pm »