lib/Sort/DataTypes.pm

filter: Statementstmt 56.3% 381 / 676 Branchbran 45.8% 134 / 292 Conditioncond 40.2% 110 / 273 MC/DCmcdc 21.7% 30 / 138 Subroutinesub 45.6% 53 / 116 Podpod 100% 76 / 76 totaltotal 49.9% 784 / 1571 CC 241 SCAR 31.6
CC
241
Cov
50%
__cmp_partial
125.5
_ip
56.0
sort_rev_line
42.0
CRAP 23.5
↑ Summary
1 package Sort::DataTypes;
2 # Copyright (c) 2007-2011 Sullivan Beck. All rights reserved.
3 # This program is free software; you can redistribute it and/or modify it
4 # under the same terms as Perl itself.
5  
6 ###############################################################################
7  
8 25 $VERSION = "3.01";
9  
10 25 require 5.000;
11 25 require Exporter;
12 25 ▶use Storable qw(dclone);
Subroutine BEGIN: called CC=1 SCAR=0.0
13 25 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 25 our %methods = ('alphabetic' => { 'type' => 'unambiguous',
16 'args' => [],
17 'reverse' => 0,
18 },
19 'numerical' => { 'type' => 'unambiguous',
20 'args' => [],
21 'reverse' => 0,
22 },
23 'alphanum' => { 'type' => 'unambiguous',
24 'args' => [],
25 'reverse' => 0,
26 },
27 'random' => { 'type' => 'unambiguous',
28 'args' => [],
29 'reverse' => 0,
30 },
31 'version' => { 'type' => 'unambiguous',
32 'args' => [],
33 'reverse' => 0,
34 },
35 'date' => { 'type' => 'unambiguous',
36 'args' => [],
37 'reverse' => 0,
38 },
39 'ip' => { 'type' => 'unambiguous',
40 'args' => [],
41 'reverse' => 0,
42 },
43 'nosort' => { 'type' => 'unambiguous',
44 'args' => [],
45 'reverse' => 0,
46 },
47 'function' => { 'type' => 'unambiguous',
48 'args' => [],
49 'reverse' => 0,
50 'args' => [ { 'type' => 'function',
51 },
52 { 'type' => 'string',
53 },
54 ],
55 },
56  
57 'length' => { 'type' => 'ambiguous',
58 'args' => [],
59 'alt' => 'alphabetic',
60 'altargs' => [],
61 'reverse' => 0,
62 },
63  
64 'split' => { 'type' => 'split',
65 'args' => [ { 'type' => 'member',
66 'values' => [ 'lms', 'rms' ],
67 'default' => 'lms',
68 },
69 {
70 'type' => 'regexp',
71 'default' => '\s+',
72 }
73 ],
74 'alt' => 'alphabetic',
75 'altargs' => [],
76 'reverse' => 0,
77 },
78  
79 'domain' => { 'type' => 'wrapper' },
80 'numdomain' => { 'type' => 'wrapper' },
81 'path' => { 'type' => 'wrapper' },
82 'numpath' => { 'type' => 'wrapper' },
83  
84 'partial' => { 'type' => 'partial',
85 'args' => [ {
86 'type' => 'regexp',
87 'default' => '\s+',
88 }
89 ],
90 'alt' => 'alphabetic',
91 'altargs' => [],
92 'reverse' => 0,
93 },
94  
95 'line' => { 'type' => 'wrapper' },
96 'numline' => { 'type' => 'wrapper' },
97 );
98 25 my @all_methods = map { ("sort_$_", "sort_rev_$_", "cmp_$_", "cmp_rev_$_") } keys %methods;
99  
100 25 @ISA = qw(Exporter);
101 25 @EXPORT_OK = (
102 qw(sort_valid_method
103 sort_by_method
104 cmp_valid_method
105 cmp_by_method
106 ),
107 @all_methods);
108 25 %EXPORT_TAGS = (all => \@EXPORT_OK);
109  
110 25 foreach my $meth (keys %methods) {
111 450 $methods{$meth}{'function'} = $meth;
112 450 $methods{"rev_$meth"} = dclone($methods{$meth});
113 450 $methods{"rev_$meth"}{'reverse'} = 1;
114 }
115  
116 25 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
117 ###############################################################################
118 ###############################################################################
119  
120 7 ▶sub sort_valid_method {
Subroutine sort_valid_method: called CC=2 SCAR=6.9
Pod documented
121 7 my($method) = @_;
122 7 ▶ return (exists $methods{$method} ? 1 : 0);
Branch: 1 branch
BranchTrueFalseTotal
exists $Sort::DataTypes::methods{$method} ? : 6 1 7
123 }
124  
125 0 ▶sub cmp_valid_method {
Subroutine cmp_valid_method: not called CC=2 SCAR=17.9
Pod documented
126 0 my($method) = @_;
127 0 ▶ return (exists $methods{$method} ? 1 : 0);
Branch: 1 branch
BranchTrueFalseTotal
exists $Sort::DataTypes::methods{$method} ? : 0 0 0
128 }
129  
130 4 ▶sub sort_by_method {
Subroutine sort_by_method: called CC=2 SCAR=7.0
Pod documented
131 4 my($method,$list,@args) = @_;
132  
133 4 ▶ return if (! sort_valid_method($method));
Branch: 1 branch
BranchTrueFalseTotal
unless sort_valid_method($method) 0 4 4
134 25 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
135 4 my $func = "sort_$method";
136 4 return &$func($list,@args);
137 }
138  
139 0 ▶sub cmp_by_method {
Subroutine cmp_by_method: not called CC=2 SCAR=11.6
Pod documented
140 0 my($method,$list,@args) = @_;
141  
142 0 ▶ return if (! cmp_valid_method($method));
Branch: 1 branch
BranchTrueFalseTotal
unless cmp_valid_method($method) 0 0 0
143 25 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
144 0 my $func = "cmp_$method";
145 0 return &$func($list,@args);
146 }
147  
148 ###############################################################################
149 # UNAMBIGUOUS METHODS
150 ###############################################################################
151  
152 3 ▶sub sort_numerical {
Subroutine sort_numerical: called CC=1 SCAR=0.0
Pod documented
153 3 return _sort('','numerical',@_);
154 }
155  
156 3 ▶sub cmp_numerical {
Subroutine cmp_numerical: called CC=1 SCAR=0.0
Pod documented
157 3 return _cmp('','numerical',@_);
158 }
159  
160 3 ▶sub sort_rev_numerical {
Subroutine sort_rev_numerical: called CC=1 SCAR=0.0
Pod documented
161 3 return _sort('rev','numerical',@_);
162 }
163  
164 3 ▶sub cmp_rev_numerical {
Subroutine cmp_rev_numerical: called CC=1 SCAR=0.0
Pod documented
165 3 return _cmp('rev','numerical',@_);
166 }
167  
168 38 ▶sub _numerical {
Subroutine _numerical: called CC=5 SCAR=17.2
169 38 my($ele) = @_;
170 38 ▶ return 0 if (! defined($ele) || ref($ele));
Branch: 1 branch
BranchTrueFalseTotal
if not defined $ele or ref $ele 0 38 38
Condition33%1/3
not defined $ele or ref $ele
l!l&&r!l&&!r
0038
MC/DC0%0/2
not defined $ele or ref $ele
not defined $ele ref $ele
Truth table33%1/3
not(A) or B
A= not defined $eleB= ref $ele
ABresult
1X1
011
000
171 38 ▶ return 1 if ($ele =~ /^[+-]?\d+\.?\d*$/ ||
Branch: 1 branch
BranchTrueFalseTotal
if $ele =~ /^[+-]?\d+\.?\d*$/ or $ele =~ /^[+-]?\.\d+$/ 21 17 38
Condition66%2/3
$ele =~ /^[+-]?\d+\.?\d*$/ or $ele =~ /^[+-]?\.\d+$/
l!l&&r!l&&!r
21017
MC/DC50%1/2
$ele =~ /^[+-]?\d+\.?\d*$/ or $ele =~ /^[+-]?\.\d+$/
$ele =~ /^[+-]?\d+\.?\d*$/ $ele =~ /^[+-]?\.\d+$/
Truth table66%2/3
A or B
A= $ele =~ /^[+-]?\d+\.?\d*$/B= $ele =~ /^[+-]?\.\d+$/
ABresult
1X1
011
000
172 $ele =~ /^[+-]?\.\d+$/);
173 17 return 0;
174 }
175  
176 41 ▶sub _cmp_numerical {
Subroutine _cmp_numerical: called CC=1 SCAR=0.0
177 41 my($x,$y) = @_;
178 41 return ($x <=> $y);
179 }
180  
181 ###############################################################################
182  
183 2 ▶sub sort_alphabetic {
Subroutine sort_alphabetic: called CC=1 SCAR=0.0
Pod documented
184 2 return _sort('','alphabetic',@_);
185 }
186  
187 0 ▶sub cmp_alphabetic {
Subroutine cmp_alphabetic: not called CC=1 SCAR=6.9
Pod documented
188 0 return _cmp('','alphabetic',@_);
189 }
190  
191 0 ▶sub sort_rev_alphabetic {
Subroutine sort_rev_alphabetic: not called CC=1 SCAR=6.9
Pod documented
192 0 return _sort('rev','alphabetic',@_);
193 }
194  
195 0 ▶sub cmp_rev_alphabetic {
Subroutine cmp_rev_alphabetic: not called CC=1 SCAR=6.9
Pod documented
196 0 return _cmp('rev','alphabetic',@_);
197 }
198  
199 0 ▶sub _alphabetic {
Subroutine _alphabetic: not called CC=2 SCAR=17.9
200 0 my($ele) = @_;
201 0 ▶ return 1 if (! ref($ele));
Branch: 1 branch
BranchTrueFalseTotal
unless ref $ele 0 0 0
202 0 return 0;
203 }
204  
205 102 ▶sub _cmp_alphabetic {
Subroutine _cmp_alphabetic: called CC=1 SCAR=0.0
206 102 my($x,$y) = @_;
207 102 return ($x cmp $y);
208 }
209  
210 ###############################################################################
211  
212 2 ▶sub sort_alphanum {
Subroutine sort_alphanum: called CC=1 SCAR=0.0
Pod documented
213 2 return _sort('','alphanum',@_);
214 }
215  
216 0 ▶sub cmp_alphanum {
Subroutine cmp_alphanum: not called CC=1 SCAR=6.9
Pod documented
217 0 return _cmp('','alphanum',@_);
218 }
219  
220 0 ▶sub sort_rev_alphanum {
Subroutine sort_rev_alphanum: not called CC=1 SCAR=6.9
Pod documented
221 0 return _sort('rev','alphanum',@_);
222 }
223  
224 0 ▶sub cmp_rev_alphanum {
Subroutine cmp_rev_alphanum: not called CC=1 SCAR=6.9
Pod documented
225 0 return _cmp('rev','alphanum',@_);
226 }
227  
228 0 ▶sub _alphanum {
Subroutine _alphanum: not called CC=2 SCAR=17.9
229 0 my($ele) = @_;
230 0 ▶ return 1 if (! ref($ele));
Branch: 1 branch
BranchTrueFalseTotal
unless ref $ele 0 0 0
231 0 return 0;
232 }
233  
234 26 ▶sub _cmp_alphanum {
Subroutine _cmp_alphanum: called CC=3 SCAR=11.0
235 26 my($x,$y) = @_;
236 26 ▶ if (_numerical($x) && _numerical($y)) {
Branch: 1 branch
BranchTrueFalseTotal
if (_numerical($x) and _numerical($y)) { } 9 17 26
Condition100%3/3
_numerical($x) and _numerical($y)
!ll&&!rl&&r
1439
MC/DC100%2/2
_numerical($x) and _numerical($y)
_numerical($x) _numerical($y)
Truth table100%3/3
A and B
A= _numerical($x)B= _numerical($y)
ABresult
0X0
100
111
237 9 return ($x <=> $y);
238 } else {
239 17 return ($x cmp $y);
240 }
241 }
242  
243 ###############################################################################
244  
245 {
246 25 my $randomized = 0;
247  
248 0 ▶ sub _randomize {
Subroutine _randomize: not called CC=1 SCAR=6.9
249 0 $randomized = 1;
250 0 srand(time);
251 }
252  
253 0 ▶ sub sort_random {
Subroutine sort_random: not called CC=2 SCAR=17.9
Pod documented
254 0 ▶ _randomize() if (! $randomized);
Branch: 1 branch
BranchTrueFalseTotal
unless $randomized 0 0 0
255 0 return _sort('','random',@_);
256 }
257  
258 0 ▶ sub cmp_random {
Subroutine cmp_random: not called CC=2 SCAR=17.9
Pod documented
259 0 ▶ _randomize() if (! $randomized);
Branch: 1 branch
BranchTrueFalseTotal
unless $randomized 0 0 0
260 0 return _cmp('','random',@_);
261 }
262  
263 0 ▶ sub sort_rev_random {
Subroutine sort_rev_random: not called CC=2 SCAR=17.9
Pod documented
264 0 ▶ _randomize() if (! $randomized);
Branch: 1 branch
BranchTrueFalseTotal
unless $randomized 0 0 0
265 0 return _sort('','random',@_);
266 }
267  
268 0 ▶ sub cmp_rev_random {
Subroutine cmp_rev_random: not called CC=2 SCAR=17.9
Pod documented
269 0 ▶ _randomize() if (! $randomized);
Branch: 1 branch
BranchTrueFalseTotal
unless $randomized 0 0 0
270 0 return _cmp('','random',@_);
271 }
272  
273 0 ▶ sub _random {
Subroutine _random: not called CC=1 SCAR=6.9
274 0 my($ele) = @_;
275 0 return 1;
276 }
277  
278 0 ▶ sub _cmp_random {
Subroutine _cmp_random: not called CC=1 SCAR=6.9
279 0 my($x,$y) = @_;
280 0 return int(rand(3)) - 1;
281 }
282 }
283  
284 ###############################################################################
285  
286 25 ▶sub sort_version {
Subroutine sort_version: called CC=1 SCAR=0.0
Pod documented
287 5 return _sort('','version',@_);
288 }
289  
290 0 ▶sub cmp_version {
Subroutine cmp_version: not called CC=1 SCAR=6.9
Pod documented
291 0 return _cmp('','version',@_);
292 }
293  
294 0 ▶sub sort_rev_version {
Subroutine sort_rev_version: not called CC=1 SCAR=6.9
Pod documented
295 0 return _sort('rev','version',@_);
296 }
297  
298 0 ▶sub cmp_rev_version {
Subroutine cmp_rev_version: not called CC=1 SCAR=6.9
Pod documented
299 0 return _cmp('rev','version',@_);
300 }
301  
302 0 ▶sub _version {
Subroutine _version: not called CC=2 SCAR=17.9
303 0 my($ele) = @_;
304 0 ▶ return 1 if (! ref($ele));
Branch: 1 branch
BranchTrueFalseTotal
unless ref $ele 0 0 0
305 0 return 0;
306 }
307  
308 9 ▶sub _cmp_version {
Subroutine _cmp_version: called CC=16 SCAR=29.5
309 9 my($x,$y) = @_;
310  
311 9 my(@x,@y);
312 9 (@x)=split(/\./,$x);
313 9 (@y)=split(/\./,$y);
314  
315 9 ▶ while (@x) {
Branch: 1 branch
BranchTrueFalseTotal
if (@x) 19 0 19
316 19 ▶ return 1 if (! @y);
Branch: 1 branch
BranchTrueFalseTotal
unless @y 1 18 19
317 18 my $xx=shift(@x);
318 18 my $yy=shift(@y);
319  
320 18 ▶ if ($xx =~ /^(\d+)(.*)$/) {
Branch: 3 branches
BranchTrueFalseTotal
if ($xx =~ /^(\d+)(.*)$/) { } 16 2 18
elsif ($yy =~ /^(\d+)(.*)$/) { } 1 1 2
elsif ($xx or $yy) { } 1 0 1
321 16 my($xv,$xs) = ($1+0,$2);
322 16 ▶ if ($yy =~ /^(\d+)(.*)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($yy =~ /^(\d+)(.*)$/) { } 16 0 16
323 16 my($yv,$ys) = ($1+0,$2);
324 16 my $ret = ($xv <=> $yv);
325 16 ▶ return $ret if ($ret);
Branch: 1 branch
BranchTrueFalseTotal
if $ret 4 12 16
326 12 ▶ return -1 if ($xs && ! $ys);
Branch: 1 branch
BranchTrueFalseTotal
if $xs and not $ys 1 11 12
Condition100%3/3
$xs and not $ys
!ll&&!rl&&r
1011
MC/DC100%2/2
$xs and not $ys
$xs not $ys
Truth table100%3/3
A and not(B)
A= $xsB= not $ys
ABresult
0X0
100
111
327 11 ▶ return 1 if ($ys && ! $xs);
Branch: 1 branch
BranchTrueFalseTotal
if $ys and not $xs 0 11 11
Condition66%2/3
$ys and not $xs
!ll&&!rl&&r
1010
MC/DC0%0/2
$ys and not $xs
$ys not $xs
Truth table66%2/3
A and not(B)
A= $ysB= not $xs
ABresult
0X0
100
111
328 11 $ret = ($xx cmp $yy);
329 11 ▶ return $ret if ($ret);
Branch: 1 branch
BranchTrueFalseTotal
if $ret 1 10 11
330 } else {
331 0 return 1;
332 }
333 } elsif ($yy =~ /^(\d+)(.*)$/) {
334 1 return -1;
335 ▶ } elsif ($xx || $yy) {
Condition33%1/3
$xx or $yy
l!l&&r!l&&!r
100
MC/DC0%0/2
$xx or $yy
$xx $yy
Truth table33%1/3
A or B
A= $xxB= $yy
ABresult
1X1
011
000
336 1 my $ret=($xx cmp $yy);
337 1 ▶ return $ret if ($ret);
Branch: 1 branch
BranchTrueFalseTotal
if $ret 1 0 1
338 }
339 }
340 0 ▶ return -1 if (@y);
Branch: 1 branch
BranchTrueFalseTotal
if @y 0 0 0
341 0 return 0;
342 }
343  
344 ###############################################################################
345  
346 {
347 25 my $date_init = 0;
348 25 my %cache;
349  
350 1 ▶ sub sort_date {
Subroutine sort_date: called CC=2 SCAR=7.0
Pod documented
351 1 %cache = ();
352 1 ▶ if (! $date_init) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($date_init) 1 0 1
353 1 require Date::Manip;
354 1 Date::Manip::Date_Init();
355 1 $date_init = 1;
356 }
357 1 return _sort('','date',@_);
358 }
359  
360 0 ▶ sub cmp_date {
Subroutine cmp_date: not called CC=2 SCAR=17.9
Pod documented
361 0 %cache = ();
362 0 ▶ if (! $date_init) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($date_init) 0 0 0
363 0 require Date::Manip;
364 0 Date::Manip::Date_Init();
365 0 $date_init = 1;
366 }
367 0 return _cmp('','date',@_);
368 }
369  
370 1 ▶ sub sort_rev_date {
Subroutine sort_rev_date: called CC=2 SCAR=7.0
Pod documented
371 1 %cache = ();
372 1 ▶ if (! $date_init) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($date_init) 1 0 1
373 1 require Date::Manip;
374 1 Date::Manip::Date_Init();
375 1 $date_init = 1;
376 }
377 1 return _sort('rev','date',@_);
378 }
379  
380 0 ▶ sub cmp_rev_date {
Subroutine cmp_rev_date: not called CC=2 SCAR=17.9
Pod documented
381 0 %cache = ();
382 0 ▶ if (! $date_init) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($date_init) 0 0 0
383 0 require Date::Manip;
384 0 Date::Manip::Date_Init();
385 0 $date_init = 1;
386 }
387 0 return _cmp('rev','date',@_);
388 }
389  
390 0 ▶ sub _date {
Subroutine _date: not called CC=3 SCAR=24.8
391 0 my($ele) = @_;
392 0 ▶ $cache{$ele} = Date::Manip::ParseDate($ele) if (! exists $cache{$ele});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $cache{$ele} 0 0 0
393 0 ▶ return 1 if ($cache{$ele});
Branch: 1 branch
BranchTrueFalseTotal
if $cache{$ele} 0 0 0
394 0 return 0;
395 }
396  
397 10 ▶ sub _cmp_date {
Subroutine _cmp_date: called CC=3 SCAR=11.0
398 10 my($x,$y) = @_;
399  
400 10 ▶ $cache{$x} = Date::Manip::ParseDate($x) if (! exists $cache{$x});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $cache{$x} 4 6 10
401 10 ▶ $cache{$y} = Date::Manip::ParseDate($y) if (! exists $cache{$y});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $cache{$y} 4 6 10
402  
403 10 return $cache{$x} cmp $cache{$y};
404 }
405 }
406  
407 ###############################################################################
408  
409 25 ▶sub sort_ip {
Subroutine sort_ip: called CC=1 SCAR=0.0
Pod documented
410 2 return _sort('','ip',@_);
411 }
412  
413 0 ▶sub cmp_ip {
Subroutine cmp_ip: not called CC=1 SCAR=6.9
Pod documented
414 0 return _cmp('','ip',@_);
415 }
416  
417 0 ▶sub sort_rev_ip {
Subroutine sort_rev_ip: not called CC=1 SCAR=6.9
Pod documented
418 0 return _sort('rev','ip',@_);
419 }
420  
421 0 ▶sub cmp_rev_ip {
Subroutine cmp_rev_ip: not called CC=1 SCAR=6.9
Pod documented
422 0 return _cmp('rev','ip',@_);
423 }
424  
425 0 ▶sub _ip {
Subroutine _ip: not called CC=7 SCAR=40.3
426 0 my($ele) = @_;
427 0 ▶ return 0 unless ($ele =~ /^([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)(?:\/([0-9]+))?$/);
Branch: 1 branch
BranchTrueFalseTotal
unless $ele =~ m[^([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)(?:/([0-9]+))?$] 0 0 0
428 0 my ($a,$b,$c,$d,$m) = ($1,$2,$3,$4,$5);
429 0 ▶ return 0 if ($a > 255 ||
Branch: 1 branch
BranchTrueFalseTotal
if $a > 255 or $b > 255 or $c > 255 or $d > 255 or $m > 32 0 0 0
Condition0%0/12
$a > 255 or $b > 255 or $c > 255 or $d > 255 or $m > 32
l!l&&r!l&&!r
000
$a > 255 or $b > 255 or $c > 255 or $d > 255
l!l&&r!l&&!r
000
$a > 255 or $b > 255 or $c > 255
l!l&&r!l&&!r
000
$a > 255 or $b > 255
l!l&&r!l&&!r
000
MC/DC0%0/5
$a > 255 or $b > 255 or $c > 255 or $d > 255 or $m > 32
$a > 255 $b > 255 $c > 255 $d > 255 $m > 32
Truth table0%0/6
A or B or C or D or E
A= $a > 255B= $b > 255C= $c > 255D= $d > 255E= $m > 32
ABCDEresult
1XXXX1
01XXX1
001XX1
0001X1
000011
000000
430 $b > 255 ||
431 $c > 255 ||
432 $d > 255 ||
433 $m > 32);
434 0 return 1;
435 }
436  
437 14 ▶sub _cmp_ip {
Subroutine _cmp_ip: called CC=14 SCAR=27.6
438 14 my($x,$y) = @_;
439 14 my(@x,@y);
440 14 $x =~ /^([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)(?:\/([0-9]+))?$/;
441 14 @x = ($1,$2,$3,$4,$5);
442 14 $y =~ /^([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)(?:\/([0-9]+))?$/;
443 14 @y = ($1,$2,$3,$4,$5);
444 14 ▶ return ($x[0] <=> $y[0] ||
Condition75%27/36
$x[0] <=> $y[0] || $x[1] <=> $y[1] || $x[2] <=> $y[2] || $x[3] <=> $y[3] || defined $x[4] && !defined($y[4]) && 1 || !defined($x[4]) && defined $y[4] && -1 || defined $x[4] && defined $y[4] && $x[4] <=> $y[4] || 0
l!l
140
$x[0] <=> $y[0] or $x[1] <=> $y[1] or $x[2] <=> $y[2] or $x[3] <=> $y[3] or defined $x[4] and not defined $y[4] and 1 or not defined $x[4] and defined $y[4] and -1 or defined $x[4] and defined $y[4] and $x[4] <=> $y[4]
l!l&&r!l&&!r
1310
$x[0] <=> $y[0] or $x[1] <=> $y[1] or $x[2] <=> $y[2] or $x[3] <=> $y[3] or defined $x[4] and not defined $y[4] and 1 or not defined $x[4] and defined $y[4] and -1
l!l&&r!l&&!r
1211
$x[0] <=> $y[0] or $x[1] <=> $y[1] or $x[2] <=> $y[2] or $x[3] <=> $y[3] or defined $x[4] and not defined $y[4] and 1
l!l&&r!l&&!r
1112
$x[0] <=> $y[0] or $x[1] <=> $y[1] or $x[2] <=> $y[2] or $x[3] <=> $y[3]
l!l&&r!l&&!r
383
$x[0] <=> $y[0] or $x[1] <=> $y[1] or $x[2] <=> $y[2]
l!l&&r!l&&!r
3011
$x[0] <=> $y[0] or $x[1] <=> $y[1]
l!l&&r!l&&!r
3011
defined $x[4] and not defined $y[4] and 1
!ll
21
defined $x[4] and not defined $y[4]
!ll&&!rl&&r
111
not defined $x[4] and defined $y[4] and -1
!ll
11
not defined $x[4] and defined $y[4]
!ll&&!rl&&r
101
defined $x[4] and defined $y[4] and $x[4] <=> $y[4]
!ll&&!rl&&r
001
defined $x[4] and defined $y[4]
!ll&&!rl&&r
001
MC/DC0%0/11
$x[0] <=> $y[0] || $x[1] <=> $y[1] || $x[2] <=> $y[2] || $x[3] <=> $y[3] || defined $x[4] && !defined($y[4]) && 1 || !defined($x[4]) && defined $y[4] && -1 || defined $x[4] && defined $y[4] && $x[4] <=> $y[4] || 0
$x[0] <=> $y[0] $x[1] <=> $y[1] $x[2] <=> $y[2] $x[3] <=> $y[3] defined $x[4] not defined $y[4] not defined $x[4] defined $y[4] defined $x[4] defined $y[4] $x[4] <=> $y[4]
Truth table21%5/23
A or B or C or D or E and not(F) or not(G) and H or I and J and K
A= $x[0] <=> $y[0]B= $x[1] <=> $y[1]C= $x[2] <=> $y[2]D= $x[3] <=> $y[3]E= defined $x[4]F= not defined $y[4]G= not defined $x[4]H= defined $y[4]I= defined $x[4]J= defined $y[4]K= $x[4] <=> $y[4]
ABCDEFGHIJKresult
1XXXXXXXXXX1
01XXXXXXXXX1
001XXXXXXXX1
0001XXXXXXX1
000011XXXXX1
00000X11XXX1
00001011XXX1
00000X0X1111
00000X101111
0000100X1111
000010101111
00000X0X0XX0
00000X0X10X0
00000X0X1100
00000X100XX0
00000X1010X0
00000X101100
0000100X0XX0
0000100X10X0
0000100X1100
000010100XX0
0000101010X0
000010101100
445 $x[1] <=> $y[1] ||
446 $x[2] <=> $y[2] ||
447 $x[3] <=> $y[3] ||
448 (defined $x[4] && ! defined $y[4] && 1) ||
449 (! defined $x[4] && defined $y[4] && -1) ||
450 (defined $x[4] && defined $y[4] && $x[4] <=> $y[4]) ||
451 0);
452 }
453  
454 ###############################################################################
455 1 ▶sub sort_nosort {
Subroutine sort_nosort: called CC=1 SCAR=0.0
Pod documented
456 1 return 1;
457 }
458  
459 0 ▶sub cmp_nosort {
Subroutine cmp_nosort: not called CC=1 SCAR=6.9
Pod documented
460 0 return -1;
461 }
462  
463 0 ▶sub sort_rev_nosort {
Subroutine sort_rev_nosort: not called CC=1 SCAR=6.9
Pod documented
464 0 return 1;
465 }
466  
467 0 ▶sub cmp_rev_nosort {
Subroutine cmp_rev_nosort: not called CC=1 SCAR=6.9
Pod documented
468 0 return -1;
469 }
470  
471 ###############################################################################
472  
473 3 ▶sub sort_function {
Subroutine sort_function: called CC=1 SCAR=0.0
Pod documented
474 3 my $caller = ( caller )[0];
475 3 return _sort('','function',@_,$caller);
476 }
477  
478 0 ▶sub cmp_function {
Subroutine cmp_function: not called CC=1 SCAR=6.9
Pod documented
479 0 my $caller = ( caller )[0];
480 0 return _cmp('','function',@_,$caller);
481 }
482  
483 0 ▶sub sort_rev_function {
Subroutine sort_rev_function: not called CC=1 SCAR=6.9
Pod documented
484 0 my $caller = ( caller )[0];
485 0 return _sort('rev','function',@_,$caller);
486 }
487  
488 0 ▶sub cmp_rev_function {
Subroutine cmp_rev_function: not called CC=1 SCAR=6.9
Pod documented
489 0 my $caller = ( caller )[0];
490 0 return _cmp('rev','function',@_,$caller);
491 }
492  
493 0 ▶sub _function {
Subroutine _function: not called CC=1 SCAR=6.9
494 0 return 1;
495 }
496  
497 28 ▶sub _cmp_function {
Subroutine _cmp_function: called CC=3 SCAR=11.0
498 28 my($x,$y,$args) = @_;
499 28 my ($func,$caller) = @$args;
500 25 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
501 28 ▶ if (ref($func) eq 'CODE' || $func =~ /::/) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $func eq 'CODE' or $func =~ /::/) { } 16 12 28
Condition100%3/3
ref $func eq "CODE" or $func =~ /::/
l!l&&r!l&&!r
41212
MC/DC100%2/2
ref $func eq "CODE" or $func =~ /::/
ref $func eq "CODE" $func =~ /::/
Truth table100%3/3
A or B
A= ref $func eq "CODE"B= $func =~ /::/
ABresult
1X1
011
000
502 16 return &$func($x,$y);
503 } else {
504 12 $func = $caller . "::$func";
505 12 return &$func($x,$y);
506 }
507 }
508  
509 ###############################################################################
510 # AMBIGUOUS METHODS
511 ###############################################################################
512  
513 4 ▶sub sort_length {
Subroutine sort_length: called CC=1 SCAR=0.0
Pod documented
514 4 return _sort('','length',@_);
515 }
516  
517 0 ▶sub cmp_length {
Subroutine cmp_length: not called CC=1 SCAR=6.9
Pod documented
518 0 return _cmp('','length',@_);
519 }
520  
521 0 ▶sub sort_rev_length {
Subroutine sort_rev_length: not called CC=1 SCAR=6.9
Pod documented
522 0 return _sort('rev','length',@_);
523 }
524  
525 0 ▶sub cmp_rev_length {
Subroutine cmp_rev_length: not called CC=1 SCAR=6.9
Pod documented
526 0 return _cmp('rev','length',@_);
527 }
528  
529 0 ▶sub _length {
Subroutine _length: not called CC=2 SCAR=17.9
530 0 my($ele) = @_;
531 0 ▶ return 1 if (! ref($ele));
Branch: 1 branch
BranchTrueFalseTotal
unless ref $ele 0 0 0
532 0 return 0;
533 }
534  
535 27 ▶sub _cmp_length {
Subroutine _cmp_length: called CC=1 SCAR=0.0
536 27 my($x,$y) = @_;
537 27 return ( length($x) <=> length($y) );
538 }
539  
540 ###############################################################################
541 # SPLIT-ELEMENT METHODS
542 ###############################################################################
543  
544 17 ▶sub sort_split {
Subroutine sort_split: called CC=1 SCAR=0.0
Pod documented
545 17 return _sort_split('','split',@_);
546 }
547  
548 0 ▶sub cmp_split {
Subroutine cmp_split: not called CC=1 SCAR=6.9
Pod documented
549 0 return _cmp_split('','split',@_);
550 }
551  
552 1 ▶sub sort_rev_split {
Subroutine sort_rev_split: called CC=1 SCAR=0.0
Pod documented
553 1 return _sort_split('rev','split',@_);
554 }
555  
556 0 ▶sub cmp_rev_split {
Subroutine cmp_rev_split: not called CC=1 SCAR=6.9
Pod documented
557 0 return _cmp_split('rev','split',@_);
558 }
559  
560 ###############################################################################
561  
562 7 ▶sub sort_domain {
Subroutine sort_domain: called CC=4 SCAR=14.5
Pod documented
563 7 my($listref,@args) = @_;
564 7 ▶ if (@args && (ref($args[0]) eq '' || ref($args[0]) eq 'Regexp')) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args and ref $args[0] eq '' || ref $args[0] eq 'Regexp') { } 6 1 7
Condition50%3/6
@args and ref $args[0] eq "" || ref $args[0] eq "Regexp"
!ll&&!rl&&r
106
ref $args[0] eq "" or ref $args[0] eq "Regexp"
l!l&&r!l&&!r
600
MC/DC33%1/3
@args and ref $args[0] eq "" || ref $args[0] eq "Regexp"
@args ref $args[0] eq "" ref $args[0] eq "Regexp"
Truth table50%2/4
A and B or C
A= @argsB= ref $args[0] eq ""C= ref $args[0] eq "Regexp"
ABCresult
0XX0
1000
11X1
1011
565 6 return sort_split($listref,'rms',@args);
566 } else {
567 1 return sort_split($listref,'rms',qr/\./,@args);
568 }
569 }
570  
571 0 ▶sub cmp_domain {
Subroutine cmp_domain: not called CC=4 SCAR=30.0
Pod documented
572 0 my($x,$y,@args) = @_;
573 0 ▶ if (@args && (ref($args[0]) eq '' || ref($args[0]) eq 'Regexp')) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args and ref $args[0] eq '' || ref $args[0] eq 'Regexp') { } 0 0 0
Condition0%0/6
@args and ref $args[0] eq "" || ref $args[0] eq "Regexp"
!ll&&!rl&&r
000
ref $args[0] eq "" or ref $args[0] eq "Regexp"
l!l&&r!l&&!r
000
MC/DC0%0/3
@args and ref $args[0] eq "" || ref $args[0] eq "Regexp"
@args ref $args[0] eq "" ref $args[0] eq "Regexp"
Truth table0%0/4
A and B or C
A= @argsB= ref $args[0] eq ""C= ref $args[0] eq "Regexp"
ABCresult
0XX0
1000
11X1
1011
574 0 return cmp_split($x.$y,'rms',@args);
575 } else {
576 0 return cmp_split($x,$y,'rms',qr/\./,@args);
577 }
578 }
579  
580 1 ▶sub sort_rev_domain {
Subroutine sort_rev_domain: called CC=4 SCAR=17.9
Pod documented
581 1 my($listref,@args) = @_;
582 1 ▶ if (@args && (ref($args[0]) eq '' || ref($args[0]) eq 'Regexp')) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args and ref $args[0] eq '' || ref $args[0] eq 'Regexp') { } 1 0 1
Condition33%2/6
@args and ref $args[0] eq "" || ref $args[0] eq "Regexp"
!ll&&!rl&&r
001
ref $args[0] eq "" or ref $args[0] eq "Regexp"
l!l&&r!l&&!r
100
MC/DC0%0/3
@args and ref $args[0] eq "" || ref $args[0] eq "Regexp"
@args ref $args[0] eq "" ref $args[0] eq "Regexp"
Truth table25%1/4
A and B or C
A= @argsB= ref $args[0] eq ""C= ref $args[0] eq "Regexp"
ABCresult
0XX0
1000
11X1
1011
583 1 return sort_rev_split($listref,'rms',@args);
584 } else {
585 0 return sort_rev_split($listref,'rms',qr/\./,@args);
586 }
587 }
588  
589 0 ▶sub cmp_rev_domain {
Subroutine cmp_rev_domain: not called CC=4 SCAR=30.0
Pod documented
590 0 my($x,$y,@args) = @_;
591 0 ▶ if (@args && (ref($args[0]) eq '' || ref($args[0]) eq 'Regexp')) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args and ref $args[0] eq '' || ref $args[0] eq 'Regexp') { } 0 0 0
Condition0%0/6
@args and ref $args[0] eq "" || ref $args[0] eq "Regexp"
!ll&&!rl&&r
000
ref $args[0] eq "" or ref $args[0] eq "Regexp"
l!l&&r!l&&!r
000
MC/DC0%0/3
@args and ref $args[0] eq "" || ref $args[0] eq "Regexp"
@args ref $args[0] eq "" ref $args[0] eq "Regexp"
Truth table0%0/4
A and B or C
A= @argsB= ref $args[0] eq ""C= ref $args[0] eq "Regexp"
ABCresult
0XX0
1000
11X1
1011
592 0 return cmp_rev_split($x,$y,'rms',@args);
593 } else {
594 0 return cmp_rev_split($x,$y,'rms',qr/\./,@args);
595 }
596 }
597  
598 ###############################################################################
599  
600 1 ▶sub sort_numdomain {
Subroutine sort_numdomain: called CC=4 SCAR=16.0
Pod documented
601 1 my($listref,@args) = @_;
602  
603 1 $methods{'split'}{'alt'} = 'alphanum';
604 1 $methods{'rev_split'}{'alt'} = 'alphanum';
605  
606 1 my $ret;
607 1 ▶ if (@args && (ref($args[0]) eq '' || ref($args[0]) eq 'Regexp')) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args and ref $args[0] eq '' || ref $args[0] eq 'Regexp') { } 0 1 1
Condition16%1/6
@args and ref $args[0] eq "" || ref $args[0] eq "Regexp"
!ll&&!rl&&r
100
ref $args[0] eq "" or ref $args[0] eq "Regexp"
l!l&&r!l&&!r
000
MC/DC0%0/3
@args and ref $args[0] eq "" || ref $args[0] eq "Regexp"
@args ref $args[0] eq "" ref $args[0] eq "Regexp"
Truth table25%1/4
A and B or C
A= @argsB= ref $args[0] eq ""C= ref $args[0] eq "Regexp"
ABCresult
0XX0
1000
11X1
1011
608 0 $ret = sort_split($listref,'rms',@args);
609 } else {
610 1 $ret = sort_split($listref,'rms',qr/\./,@args);
611 }
612  
613 1 $methods{'split'}{'alt'} = 'alphabetic';
614 1 $methods{'rev_split'}{'alt'} = 'alphabetic';
615 1 return $ret;
616 }
617  
618 0 ▶sub cmp_numdomain {
Subroutine cmp_numdomain: not called CC=4 SCAR=30.0
Pod documented
619 0 my($x,$y,@args) = @_;
620  
621 0 $methods{'split'}{'alt'} = 'alphanum';
622 0 $methods{'rev_split'}{'alt'} = 'alphanum';
623  
624 0 my $ret;
625 0 ▶ if (@args && (ref($args[0]) eq '' || ref($args[0]) eq 'Regexp')) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args and ref $args[0] eq '' || ref $args[0] eq 'Regexp') { } 0 0 0
Condition0%0/6
@args and ref $args[0] eq "" || ref $args[0] eq "Regexp"
!ll&&!rl&&r
000
ref $args[0] eq "" or ref $args[0] eq "Regexp"
l!l&&r!l&&!r
000
MC/DC0%0/3
@args and ref $args[0] eq "" || ref $args[0] eq "Regexp"
@args ref $args[0] eq "" ref $args[0] eq "Regexp"
Truth table0%0/4
A and B or C
A= @argsB= ref $args[0] eq ""C= ref $args[0] eq "Regexp"
ABCresult
0XX0
1000
11X1
1011
626 0 $ret = cmp_split($x,$y,'rms',@args);
627 } else {
628 0 $ret = cmp_split($x,$y,'rms',qr/\./,@args);
629 }
630  
631 0 $methods{'split'}{'alt'} = 'alphabetic';
632 0 $methods{'rev_split'}{'alt'} = 'alphabetic';
633 0 return $ret;
634 }
635  
636 0 ▶sub sort_rev_numdomain {
Subroutine sort_rev_numdomain: not called CC=4 SCAR=30.0
Pod documented
637 0 my($listref,@args) = @_;
638  
639 0 $methods{'split'}{'alt'} = 'alphanum';
640 0 $methods{'rev_split'}{'alt'} = 'alphanum';
641  
642 0 my $ret;
643 0 ▶ if (@args && (ref($args[0]) eq '' || ref($args[0]) eq 'Regexp')) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args and ref $args[0] eq '' || ref $args[0] eq 'Regexp') { } 0 0 0
Condition0%0/6
@args and ref $args[0] eq "" || ref $args[0] eq "Regexp"
!ll&&!rl&&r
000
ref $args[0] eq "" or ref $args[0] eq "Regexp"
l!l&&r!l&&!r
000
MC/DC0%0/3
@args and ref $args[0] eq "" || ref $args[0] eq "Regexp"
@args ref $args[0] eq "" ref $args[0] eq "Regexp"
Truth table0%0/4
A and B or C
A= @argsB= ref $args[0] eq ""C= ref $args[0] eq "Regexp"
ABCresult
0XX0
1000
11X1
1011
644 0 $ret = sort_rev_split($listref,'rms',@args);
645 } else {
646 0 $ret = sort_rev_split($listref,'rms',qr/\./,@args);
647 }
648  
649 0 $methods{'split'}{'alt'} = 'alphabetic';
650 0 $methods{'rev_split'}{'alt'} = 'alphabetic';
651 0 return $ret;
652 }
653  
654 0 ▶sub cmp_rev_numdomain {
Subroutine cmp_rev_numdomain: not called CC=4 SCAR=30.0
Pod documented
655 0 my($x,$y,@args) = @_;
656  
657 0 $methods{'split'}{'alt'} = 'alphanum';
658 0 $methods{'rev_split'}{'alt'} = 'alphanum';
659  
660 0 my $ret;
661 0 ▶ if (@args && (ref($args[0]) eq '' || ref($args[0]) eq 'Regexp')) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args and ref $args[0] eq '' || ref $args[0] eq 'Regexp') { } 0 0 0
Condition0%0/6
@args and ref $args[0] eq "" || ref $args[0] eq "Regexp"
!ll&&!rl&&r
000
ref $args[0] eq "" or ref $args[0] eq "Regexp"
l!l&&r!l&&!r
000
MC/DC0%0/3
@args and ref $args[0] eq "" || ref $args[0] eq "Regexp"
@args ref $args[0] eq "" ref $args[0] eq "Regexp"
Truth table0%0/4
A and B or C
A= @argsB= ref $args[0] eq ""C= ref $args[0] eq "Regexp"
ABCresult
0XX0
1000
11X1
1011
662 0 $ret = cmp_rev_split($x,$y,'rms',@args);
663 } else {
664 0 $ret = cmp_rev_split($x,$y,'rms',qr/\./,@args);
665 }
666  
667 0 $methods{'split'}{'alt'} = 'alphabetic';
668 0 $methods{'rev_split'}{'alt'} = 'alphabetic';
669 0 return $ret;
670 }
671  
672 ###############################################################################
673  
674 5 ▶sub sort_path {
Subroutine sort_path: called CC=4 SCAR=14.5
Pod documented
675 5 my($listref,@args) = @_;
676 5 ▶ if (@args && (ref($args[0]) eq '' || ref($args[0]) eq 'Regexp')) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args and ref $args[0] eq '' || ref $args[0] eq 'Regexp') { } 1 4 5
Condition50%3/6
@args and ref $args[0] eq "" || ref $args[0] eq "Regexp"
!ll&&!rl&&r
401
ref $args[0] eq "" or ref $args[0] eq "Regexp"
l!l&&r!l&&!r
100
MC/DC33%1/3
@args and ref $args[0] eq "" || ref $args[0] eq "Regexp"
@args ref $args[0] eq "" ref $args[0] eq "Regexp"
Truth table50%2/4
A and B or C
A= @argsB= ref $args[0] eq ""C= ref $args[0] eq "Regexp"
ABCresult
0XX0
1000
11X1
1011
677 1 return sort_split($listref,'lms',@args);
678 } else {
679 4 return sort_split($listref,'lms',qr/\//,@args);
680 }
681 }
682  
683 0 ▶sub cmp_path {
Subroutine cmp_path: not called CC=4 SCAR=30.0
Pod documented
684 0 my($x,$y,@args) = @_;
685 0 ▶ if (@args && (ref($args[0]) eq '' || ref($args[0]) eq 'Regexp')) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args and ref $args[0] eq '' || ref $args[0] eq 'Regexp') { } 0 0 0
Condition0%0/6
@args and ref $args[0] eq "" || ref $args[0] eq "Regexp"
!ll&&!rl&&r
000
ref $args[0] eq "" or ref $args[0] eq "Regexp"
l!l&&r!l&&!r
000
MC/DC0%0/3
@args and ref $args[0] eq "" || ref $args[0] eq "Regexp"
@args ref $args[0] eq "" ref $args[0] eq "Regexp"
Truth table0%0/4
A and B or C
A= @argsB= ref $args[0] eq ""C= ref $args[0] eq "Regexp"
ABCresult
0XX0
1000
11X1
1011
686 0 return cmp_split($x.$y,'lms',@args);
687 } else {
688 0 return cmp_split($x,$y,'lms',qr/\//,@args);
689 }
690 }
691  
692 0 ▶sub sort_rev_path {
Subroutine sort_rev_path: not called CC=4 SCAR=30.0
Pod documented
693 0 my($listref,@args) = @_;
694 0 ▶ if (@args && (ref($args[0]) eq '' || ref($args[0]) eq 'Regexp')) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args and ref $args[0] eq '' || ref $args[0] eq 'Regexp') { } 0 0 0
Condition0%0/6
@args and ref $args[0] eq "" || ref $args[0] eq "Regexp"
!ll&&!rl&&r
000
ref $args[0] eq "" or ref $args[0] eq "Regexp"
l!l&&r!l&&!r
000
MC/DC0%0/3
@args and ref $args[0] eq "" || ref $args[0] eq "Regexp"
@args ref $args[0] eq "" ref $args[0] eq "Regexp"
Truth table0%0/4
A and B or C
A= @argsB= ref $args[0] eq ""C= ref $args[0] eq "Regexp"
ABCresult
0XX0
1000
11X1
1011
695 0 return sort_rev_split($listref,'lms',@args);
696 } else {
697 0 return sort_rev_split($listref,'lms',qr/\//,@args);
698 }
699 }
700  
701 0 ▶sub cmp_rev_path {
Subroutine cmp_rev_path: not called CC=4 SCAR=30.0
Pod documented
702 0 my($x,$y,@args) = @_;
703 0 ▶ if (@args && (ref($args[0]) eq '' || ref($args[0]) eq 'Regexp')) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args and ref $args[0] eq '' || ref $args[0] eq 'Regexp') { } 0 0 0
Condition0%0/6
@args and ref $args[0] eq "" || ref $args[0] eq "Regexp"
!ll&&!rl&&r
000
ref $args[0] eq "" or ref $args[0] eq "Regexp"
l!l&&r!l&&!r
000
MC/DC0%0/3
@args and ref $args[0] eq "" || ref $args[0] eq "Regexp"
@args ref $args[0] eq "" ref $args[0] eq "Regexp"
Truth table0%0/4
A and B or C
A= @argsB= ref $args[0] eq ""C= ref $args[0] eq "Regexp"
ABCresult
0XX0
1000
11X1
1011
704 0 return cmp_rev_split($x,$y,'lms',@args);
705 } else {
706 0 return cmp_rev_split($x,$y,'lms',qr/\//,@args);
707 }
708 }
709  
710 ###############################################################################
711  
712 1 ▶sub sort_numpath {
Subroutine sort_numpath: called CC=4 SCAR=15.2
Pod documented
713 1 my($listref,@args) = @_;
714  
715 1 $methods{'split'}{'alt'} = 'alphanum';
716 1 $methods{'rev_split'}{'alt'} = 'alphanum';
717  
718 1 my $ret;
719 1 ▶ if (@args && (ref($args[0]) eq '' || ref($args[0]) eq 'Regexp')) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args and ref $args[0] eq '' || ref $args[0] eq 'Regexp') { } 1 0 1
Condition33%2/6
@args and ref $args[0] eq "" || ref $args[0] eq "Regexp"
!ll&&!rl&&r
001
ref $args[0] eq "" or ref $args[0] eq "Regexp"
l!l&&r!l&&!r
100
MC/DC0%0/3
@args and ref $args[0] eq "" || ref $args[0] eq "Regexp"
@args ref $args[0] eq "" ref $args[0] eq "Regexp"
Truth table25%1/4
A and B or C
A= @argsB= ref $args[0] eq ""C= ref $args[0] eq "Regexp"
ABCresult
0XX0
1000
11X1
1011
720 1 $ret = sort_split($listref,'lms',@args);
721 } else {
722 0 $ret = sort_split($listref,'lms',qr/\//,@args);
723 }
724  
725 1 $methods{'split'}{'alt'} = 'alphabetic';
726 1 $methods{'rev_split'}{'alt'} = 'alphabetic';
727 1 return $ret;
728 }
729  
730 0 ▶sub cmp_numpath {
Subroutine cmp_numpath: not called CC=4 SCAR=30.0
Pod documented
731 0 my($x,$y,@args) = @_;
732  
733 0 $methods{'split'}{'alt'} = 'alphanum';
734 0 $methods{'rev_split'}{'alt'} = 'alphanum';
735  
736 0 my $ret;
737 0 ▶ if (@args && (ref($args[0]) eq '' || ref($args[0]) eq 'Regexp')) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args and ref $args[0] eq '' || ref $args[0] eq 'Regexp') { } 0 0 0
Condition0%0/6
@args and ref $args[0] eq "" || ref $args[0] eq "Regexp"
!ll&&!rl&&r
000
ref $args[0] eq "" or ref $args[0] eq "Regexp"
l!l&&r!l&&!r
000
MC/DC0%0/3
@args and ref $args[0] eq "" || ref $args[0] eq "Regexp"
@args ref $args[0] eq "" ref $args[0] eq "Regexp"
Truth table0%0/4
A and B or C
A= @argsB= ref $args[0] eq ""C= ref $args[0] eq "Regexp"
ABCresult
0XX0
1000
11X1
1011
738 0 $ret = cmp_split($x,$y,'lms',@args);
739 } else {
740 0 $ret = cmp_split($x,$y,'lms',qr/\//,@args);
741 }
742  
743 0 $methods{'split'}{'alt'} = 'alphabetic';
744 0 $methods{'rev_split'}{'alt'} = 'alphabetic';
745 0 return $ret;
746 }
747  
748 0 ▶sub sort_rev_numpath {
Subroutine sort_rev_numpath: not called CC=4 SCAR=30.0
Pod documented
749 0 my($listref,@args) = @_;
750  
751 0 $methods{'split'}{'alt'} = 'alphanum';
752 0 $methods{'rev_split'}{'alt'} = 'alphanum';
753  
754 0 my $ret;
755 0 ▶ if (@args && (ref($args[0]) eq '' || ref($args[0]) eq 'Regexp')) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args and ref $args[0] eq '' || ref $args[0] eq 'Regexp') { } 0 0 0
Condition0%0/6
@args and ref $args[0] eq "" || ref $args[0] eq "Regexp"
!ll&&!rl&&r
000
ref $args[0] eq "" or ref $args[0] eq "Regexp"
l!l&&r!l&&!r
000
MC/DC0%0/3
@args and ref $args[0] eq "" || ref $args[0] eq "Regexp"
@args ref $args[0] eq "" ref $args[0] eq "Regexp"
Truth table0%0/4
A and B or C
A= @argsB= ref $args[0] eq ""C= ref $args[0] eq "Regexp"
ABCresult
0XX0
1000
11X1
1011
756 0 $ret = sort_rev_split($listref,'lms',@args);
757 } else {
758 0 $ret = sort_rev_split($listref,'lms',qr/\//,@args);
759 }
760  
761 0 $methods{'split'}{'alt'} = 'alphabetic';
762 0 $methods{'rev_split'}{'alt'} = 'alphabetic';
763 0 return $ret;
764 }
765  
766 0 ▶sub cmp_rev_numpath {
Subroutine cmp_rev_numpath: not called CC=4 SCAR=30.0
Pod documented
767 0 my($x,$y,@args) = @_;
768  
769 0 $methods{'split'}{'alt'} = 'alphanum';
770 0 $methods{'rev_split'}{'alt'} = 'alphanum';
771  
772 0 my $ret;
773 0 ▶ if (@args && (ref($args[0]) eq '' || ref($args[0]) eq 'Regexp')) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args and ref $args[0] eq '' || ref $args[0] eq 'Regexp') { } 0 0 0
Condition0%0/6
@args and ref $args[0] eq "" || ref $args[0] eq "Regexp"
!ll&&!rl&&r
000
ref $args[0] eq "" or ref $args[0] eq "Regexp"
l!l&&r!l&&!r
000
MC/DC0%0/3
@args and ref $args[0] eq "" || ref $args[0] eq "Regexp"
@args ref $args[0] eq "" ref $args[0] eq "Regexp"
Truth table0%0/4
A and B or C
A= @argsB= ref $args[0] eq ""C= ref $args[0] eq "Regexp"
ABCresult
0XX0
1000
11X1
1011
774 0 $ret = cmp_rev_split($x,$y,'lms',@args);
775 } else {
776 0 $ret = cmp_rev_split($x,$y,'lms',qr/\//,@args);
777 }
778  
779 0 $methods{'split'}{'alt'} = 'alphabetic';
780 0 $methods{'rev_split'}{'alt'} = 'alphabetic';
781 0 return $ret;
782 }
783  
784 ###############################################################################
785 # PARTIAL-ELEMENT METHODS
786 ###############################################################################
787  
788 5 ▶sub sort_partial {
Subroutine sort_partial: called CC=1 SCAR=0.0
Pod documented
789 5 return _sort_partial('','partial',@_);
790 }
791  
792 0 ▶sub cmp_partial {
Subroutine cmp_partial: not called CC=1 SCAR=6.9
Pod documented
793 0 return _cmp_partial('','partial',@_);
794 }
795  
796 0 ▶sub sort_rev_partial {
Subroutine sort_rev_partial: not called CC=1 SCAR=6.9
Pod documented
797 0 return _sort_partial('rev','partial',@_);
798 }
799  
800 0 ▶sub cmp_rev_partial {
Subroutine cmp_rev_partial: not called CC=1 SCAR=6.9
Pod documented
801 0 return _cmp_partial('rev','partial',@_);
802 }
803  
804 ###############################################################################
805  
806 2 ▶sub sort_line {
Subroutine sort_line: called CC=6 SCAR=20.2
Pod documented
807 2 my($listref,$n,@args) = @_;
808  
809 2 my $sep;
810 2 ▶ if (@args && (ref($args[0]) eq 'Regexp' || ! ref($args[0]))) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args and ref $args[0] eq "Regexp" || !ref($args[0])) 2 0 2
Condition33%2/6
@args and ref $args[0] eq "Regexp" || !ref($args[0])
!ll&&!rl&&r
002
ref $args[0] eq "Regexp" or not ref $args[0]
l!l&&r!l&&!r
020
MC/DC0%0/3
@args and ref $args[0] eq "Regexp" || !ref($args[0])
@args ref $args[0] eq "Regexp" not ref $args[0]
Truth table25%1/4
A and B or not(C)
A= @argsB= ref $args[0] eq "Regexp"C= not ref $args[0]
ABCresult
0XX0
1000
11X1
1011
811 2 $sep = shift(@args);
812 }
813  
814 2 my $hash;
815 2 ▶ if (@args) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args) 0 2 2
816 0 $hash = shift(@args);
817 }
818  
819 2 my @a = ($listref);
820 2 ▶ push(@a,$sep) if (defined $sep);
Branch: 1 branch
BranchTrueFalseTotal
if defined $sep 2 0 2
821 2 push(@a,[$n,['alphabetic']]);
822  
823 2 return sort_partial(@a);
824 }
825  
826 0 ▶sub cmp_line {
Subroutine cmp_line: not called CC=2 SCAR=17.9
Pod documented
827 0 my($x,$y,$n,$sep) = @_;
828 0 my @a = ($x,$y);
829 0 ▶ push(@a,$sep) if (defined $sep);
Branch: 1 branch
BranchTrueFalseTotal
if defined $sep 0 0 0
830 0 push(@a,[$n,['alphabetic']]);
831  
832 0 return cmp_partial(@a);
833 }
834  
835 0 ▶sub sort_rev_line {
Subroutine sort_rev_line: not called CC=6 SCAR=37.4
Pod documented
836 0 my($listref,$n,@args) = @_;
837  
838 0 my $sep;
839 0 ▶ if (@args && (ref($args[0]) eq 'Regexp' || ! ref($args[0]))) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args and ref $args[0] eq "Regexp" || !ref($args[0])) 0 0 0
Condition0%0/6
@args and ref $args[0] eq "Regexp" || !ref($args[0])
!ll&&!rl&&r
000
ref $args[0] eq "Regexp" or not ref $args[0]
l!l&&r!l&&!r
000
MC/DC0%0/3
@args and ref $args[0] eq "Regexp" || !ref($args[0])
@args ref $args[0] eq "Regexp" not ref $args[0]
Truth table0%0/4
A and B or not(C)
A= @argsB= ref $args[0] eq "Regexp"C= not ref $args[0]
ABCresult
0XX0
1000
11X1
1011
840 0 $sep = shift(@args);
841 }
842  
843 0 my $hash;
844 0 ▶ if (@args) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args) 0 0 0
845 0 $hash = shift(@args);
846 }
847  
848 0 my @a = ($listref);
849 0 ▶ push(@a,$sep) if (defined $sep);
Branch: 1 branch
BranchTrueFalseTotal
if defined $sep 0 0 0
850 0 push(@a,[$n,['alphabetic']]);
851  
852 0 return sort_rev_partial(@a);
853 }
854  
855 0 ▶sub cmp_rev_line {
Subroutine cmp_rev_line: not called CC=2 SCAR=17.9
Pod documented
856 0 my($x,$y,$n,$sep) = @_;
857 0 my @a = ($x,$y);
858 0 ▶ push(@a,$sep) if (defined $sep);
Branch: 1 branch
BranchTrueFalseTotal
if defined $sep 0 0 0
859 0 push(@a,[$n,['alphabetic']]);
860  
861 0 return cmp_rev_partial(@a);
862 }
863  
864 ###############################################################################
865 2 ▶sub sort_numline {
Subroutine sort_numline: called CC=6 SCAR=20.2
Pod documented
866 2 my($listref,$n,@args) = @_;
867  
868 2 my $sep;
869 2 ▶ if (@args && (ref($args[0]) eq 'Regexp' || ! ref($args[0]))) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args and ref $args[0] eq "Regexp" || !ref($args[0])) 2 0 2
Condition33%2/6
@args and ref $args[0] eq "Regexp" || !ref($args[0])
!ll&&!rl&&r
002
ref $args[0] eq "Regexp" or not ref $args[0]
l!l&&r!l&&!r
020
MC/DC0%0/3
@args and ref $args[0] eq "Regexp" || !ref($args[0])
@args ref $args[0] eq "Regexp" not ref $args[0]
Truth table25%1/4
A and B or not(C)
A= @argsB= ref $args[0] eq "Regexp"C= not ref $args[0]
ABCresult
0XX0
1000
11X1
1011
870 2 $sep = shift(@args);
871 }
872  
873 2 my $hash;
874 2 ▶ if (@args) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args) 0 2 2
875 0 $hash = shift(@args);
876 }
877  
878 2 my @a = ($listref);
879 2 ▶ push(@a,$sep) if (defined $sep);
Branch: 1 branch
BranchTrueFalseTotal
if defined $sep 2 0 2
880 2 push(@a,[$n,['alphanum']]);
881  
882 2 return sort_partial(@a);
883 }
884  
885 0 ▶sub cmp_numline {
Subroutine cmp_numline: not called CC=2 SCAR=17.9
Pod documented
886 0 my($x,$y,$n,$sep) = @_;
887 0 my @a = ($x,$y);
888 0 ▶ push(@a,$sep) if (defined $sep);
Branch: 1 branch
BranchTrueFalseTotal
if defined $sep 0 0 0
889 0 push(@a,[$n,['alphanum']]);
890  
891 0 return cmp_partial(@a);
892 }
893  
894 0 ▶sub sort_rev_numline {
Subroutine sort_rev_numline: not called CC=6 SCAR=37.4
Pod documented
895 0 my($listref,$n,@args) = @_;
896  
897 0 my $sep;
898 0 ▶ if (@args && (ref($args[0]) eq 'Regexp' || ! ref($args[0]))) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args and ref $args[0] eq "Regexp" || !ref($args[0])) 0 0 0
Condition0%0/6
@args and ref $args[0] eq "Regexp" || !ref($args[0])
!ll&&!rl&&r
000
ref $args[0] eq "Regexp" or not ref $args[0]
l!l&&r!l&&!r
000
MC/DC0%0/3
@args and ref $args[0] eq "Regexp" || !ref($args[0])
@args ref $args[0] eq "Regexp" not ref $args[0]
Truth table0%0/4
A and B or not(C)
A= @argsB= ref $args[0] eq "Regexp"C= not ref $args[0]
ABCresult
0XX0
1000
11X1
1011
899 0 $sep = shift(@args);
900 }
901  
902 0 my $hash;
903 0 ▶ if (@args) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args) 0 0 0
904 0 $hash = shift(@args);
905 }
906  
907 0 my @a = ($listref);
908 0 ▶ push(@a,$sep) if (defined $sep);
Branch: 1 branch
BranchTrueFalseTotal
if defined $sep 0 0 0
909 0 push(@a,[$n,['alphanum']]);
910  
911 0 return sort_rev_partial(@a);
912 }
913  
914 0 ▶sub cmp_rev_numline {
Subroutine cmp_rev_numline: not called CC=2 SCAR=17.9
Pod documented
915 0 my($x,$y,$n,$sep) = @_;
916 0 my @a = ($x,$y);
917 0 ▶ push(@a,$sep) if (defined $sep);
Branch: 1 branch
BranchTrueFalseTotal
if defined $sep 0 0 0
918 0 push(@a,[$n,['alphanum']]);
919  
920 0 return cmp_rev_partial(@a);
921 }
922  
923 ###############################################################################
924 ###############################################################################
925  
926 # Only used for ambiguous/unambiguous comparisons.
927 26 ▶sub _sort {
Subroutine _sort: called CC=4 SCAR=13.9
928 26 my($rev,$method,@args) = @_;
929  
930 26 my($err,$list,$args,$hash,@extra) = _args_sort($method,@args);
931 26 ▶ return undef if ($err);
Branch: 1 branch
BranchTrueFalseTotal
if $err 0 26 26
932 26 ▶ return 1 if (! @$list);
Branch: 1 branch
BranchTrueFalseTotal
unless @$list 0 26 26
933  
934 # Sort the list.
935  
936 26 my @list;
937 26 ▶ if (defined $hash) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $hash) { } 2 24 26
938 2 @list = sort { __cmp($rev,$method,$$hash{$a},$$hash{$b},$args,@extra) } @$list;
939 } else {
940 24 @list = sort { __cmp($rev,$method,$a,$b,$args,@extra) } @$list;
941 }
942  
943 # Done
944  
945 26 @$list = @list;
946 26 return 1;
947 }
948  
949 # Only used for ambiguous/unambiguous comparisons.
950 6 ▶sub _cmp {
Subroutine _cmp: called CC=2 SCAR=7.0
951 6 my($rev,$method,@args) = @_;
952  
953 6 my($err,$x,$y,$args,@extra) = _args_cmp($method,@args);
954 6 ▶ return undef if ($err);
Branch: 1 branch
BranchTrueFalseTotal
if $err 0 6 6
955 6 return __cmp($rev,$method,$x,$y,$args,@extra);
956 }
957  
958 # Only used for ambiguous/unambiguous comparisons.
959 133 ▶sub __cmp {
Subroutine __cmp: called CC=13 SCAR=26.5
960 133 my($rev,$method,$x,$y,$args,@extra) = @_;
961  
962 25 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
963  
964 # Compare the two elements
965  
966 133 my($func,$cmp,$flag,$sort_type);
967  
968 133 $func = $methods{$method}{'function'};
969 133 $cmp = "_cmp_$func";
970 133 $flag = &$cmp($x,$y,$args);
971 133 ▶ return $flag if (! defined($flag));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $flag 0 133 133
972 133 $sort_type = $methods{$method}{'type'};
973  
974 133 ▶ while (! $flag && (@extra || $sort_type ne 'unambiguous')) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $flag and @extra || $sort_type ne "unambiguous") 11 133 144
Condition100%6/6
not $flag and @extra || $sort_type ne "unambiguous"
!ll&&!rl&&r
131211
@extra or $sort_type ne "unambiguous"
l!l&&r!l&&!r
562
MC/DC100%3/3
not $flag and @extra || $sort_type ne "unambiguous"
not $flag @extra $sort_type ne "unambiguous"
Truth table100%4/4
not(A) and B or C
A= not $flagB= @extraC= $sort_type ne "unambiguous"
ABCresult
0XX0
1000
11X1
1011
975 11 ▶ if (@extra) {
Branch: 1 branch
BranchTrueFalseTotal
if (@extra) { } 5 6 11
976 5 ▶ if (ref($extra[0]) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $extra[0] eq 'ARRAY') { } 5 0 5
977 5 my(@args);
978 5 ($method,@args) = @{ shift(@extra) };
979 5 ▶ if (! exists $methods{$method}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $Sort::DataTypes::methods{$method}) 0 5 5
980 0 warn "ERROR: alternate sort error - invalid method: $method\n";
981 0 return undef;
982 }
983 5 my($err,$method_args) = _args_method_args($method,\@args);
984 5 ▶ return undef if ($err);
Branch: 1 branch
BranchTrueFalseTotal
if $err 0 5 5
985 5 ▶ if (@args) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args) 0 5 5
986 0 warn "ERROR: alternate sort error - invalid arguments: @args\n";
987 0 return undef;
988 }
989 5 $args = $method_args;
990 } else {
991 0 warn "ERROR: alternate sort error - invalid definition\n";
992 0 return undef;
993 }
994  
995 } else {
996 6 $method = $methods{$method}{'alt'};
997 6 $args = $methods{$method}{'altargs'};
998 }
999 11 $func = $methods{$method}{'function'};
1000 11 $cmp = "_cmp_$func";
1001 11 $flag = &$cmp($x,$y,$args);
1002 11 ▶ return $flag if (! defined($flag));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $flag 0 11 11
1003 11 $sort_type = $methods{$method}{'type'};
1004 }
1005  
1006 # If it's reverse...
1007  
1008 133 ▶ if ($rev || $methods{$method}{'reverse'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rev or $Sort::DataTypes::methods{$method}{"reverse"}) 20 113 133
Condition100%3/3
$rev or $Sort::DataTypes::methods{$method}{"reverse"}
l!l&&r!l&&!r
155113
MC/DC100%2/2
$rev or $Sort::DataTypes::methods{$method}{"reverse"}
$rev $Sort::DataTypes::methods{$method}{"reverse"}
Truth table100%3/3
A or B
A= $revB= $Sort::DataTypes::methods{$method}{"reverse"}
ABresult
1X1
011
000
1009 20 $flag *= -1;
1010 }
1011  
1012 # Done
1013  
1014 133 return $flag;
1015 }
1016  
1017 ###############################################################################
1018  
1019 18 ▶sub _sort_split {
Subroutine _sort_split: called CC=4 SCAR=14.7
1020 18 my($rev,$method,@args) = @_;
1021  
1022 18 my($err,$list,$args,$hash,@extra) = _args_sort($method,@args);
1023 18 ▶ return undef if ($err);
Branch: 1 branch
BranchTrueFalseTotal
if $err 0 18 18
1024 18 ▶ return 1 if (! @$list);
Branch: 1 branch
BranchTrueFalseTotal
unless @$list 0 18 18
1025  
1026 # Sort the list.
1027  
1028 18 my @list;
1029 18 ▶ if (defined $hash) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $hash) { } 0 18 18
1030 0 @list = sort { __cmp_split($rev,$method,$$hash{$a},$$hash{$b},$args,@extra) } @$list;
1031 } else {
1032 18 @list = sort { __cmp_split($rev,$method,$a,$b,$args,@extra) } @$list;
1033 }
1034  
1035 # Done
1036  
1037 18 @$list = @list;
1038 18 return 1;
1039 }
1040  
1041 0 ▶sub _cmp_split {
Subroutine _cmp_split: not called CC=2 SCAR=17.9
1042 0 my($rev,$method,@args) = @_;
1043  
1044 0 my($err,$x,$y,$args,@extra) = _args_cmp($method,@args);
1045 0 ▶ return undef if ($err);
Branch: 1 branch
BranchTrueFalseTotal
if $err 0 0 0
1046 0 return __cmp_split($rev,$method,$x,$y,$args,@extra);
1047 }
1048  
1049 51 ▶sub __cmp_split {
Subroutine __cmp_split: called CC=22 SCAR=35.3
1050 51 my($rev,$method,$x,$y,$args,@extra) = @_;
1051  
1052 25 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
1053  
1054 # Compare the two elements
1055  
1056 51 my(@x,@y,$ms,$re);
1057 51 ($ms,$re) = @$args;
1058 51 @x = split($re,$x);
1059 51 @y = split($re,$y);
1060  
1061 51 my $flag = 0;
1062 51 my $sort_method;
1063  
1064 51 ▶ PIECE: while (! $flag && (@x || @y)) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $flag and @x || @y) 97 32 129
Condition66%4/6
not $flag and @x || @y
!ll&&!rl&&r
32097
@x or @y
l!l&&r!l&&!r
9430
MC/DC33%1/3
not $flag and @x || @y
not $flag @x @y
Truth table75%3/4
not(A) and B or C
A= not $flagB= @xC= @y
ABCresult
0XX0
1000
11X1
1011
1065 97 ▶ if ($ms eq 'rms') {
Branch: 1 branch
BranchTrueFalseTotal
if ($ms eq 'rms') { } 27 70 97
1066 27 $x = pop(@x);
1067 27 $y = pop(@y);
1068 } else {
1069 70 $x = shift(@x);
1070 70 $y = shift(@y);
1071 }
1072 97 $sort_method = $method;
1073  
1074 # Handle the case where one (or both) is missing
1075  
1076 97 ▶ if (! defined $x || $x eq '') {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $x or $x eq '') { } 13 84 97
elsif (not defined $y or $y eq '') { } 12 72 84
Condition100%3/3
not defined $x or $x eq ""
l!l&&r!l&&!r
31084
MC/DC100%2/2
not defined $x or $x eq ""
not defined $x $x eq ""
Truth table100%3/3
not(A) or B
A= not defined $xB= $x eq ""
ABresult
1X1
011
000
1077 13 ▶ if (! defined $y || $y eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $y or $y eq '') { } 6 7 13
Condition66%2/3
not defined $y or $y eq ""
l!l&&r!l&&!r
067
MC/DC50%1/2
not defined $y or $y eq ""
not defined $y $y eq ""
Truth table66%2/3
not(A) or B
A= not defined $yB= $y eq ""
ABresult
1X1
011
000
1078 6 $flag = 0;
1079 6 next PIECE;
1080 } else {
1081 7 $flag = -1;
1082 7 last PIECE;
1083 }
1084 ▶ } elsif (! defined $y || $y eq '') {
Condition100%3/3
not defined $y or $y eq ""
l!l&&r!l&&!r
6672
MC/DC100%2/2
not defined $y or $y eq ""
not defined $y $y eq ""
Truth table100%3/3
not(A) or B
A= not defined $yB= $y eq ""
ABresult
1X1
011
000
1085 12 $flag = 1;
1086 12 last PIECE;
1087 }
1088  
1089 # Compare two pieces
1090  
1091 72 my $sort_type = 'split';
1092  
1093 72 ▶ while (! $flag && (@extra || $sort_type ne 'unambiguous')) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $flag and @extra || $sort_type ne "unambiguous") 72 72 144
Condition83%5/6
not $flag and @extra || $sort_type ne "unambiguous"
!ll&&!rl&&r
324072
@extra or $sort_type ne "unambiguous"
l!l&&r!l&&!r
07240
MC/DC66%2/3
not $flag and @extra || $sort_type ne "unambiguous"
not $flag @extra $sort_type ne "unambiguous"
Truth table75%3/4
not(A) and B or C
A= not $flagB= @extraC= $sort_type ne "unambiguous"
ABCresult
0XX0
1000
11X1
1011
1094 72 ▶ if (@extra) {
Branch: 1 branch
BranchTrueFalseTotal
if (@extra) { } 0 72 72
1095 0 ▶ if (ref($extra[0]) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $extra[0] eq 'ARRAY') { } 0 0 0
1096 0 my(@args);
1097 0 ($sort_method,@args) = @{ shift(@extra) };
1098 0 ▶ if (! exists $methods{$sort_method}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $Sort::DataTypes::methods{$sort_method}) 0 0 0
1099 0 warn "ERROR: alternate sort error - invalid method: $sort_method\n";
1100 0 return undef;
1101 }
1102 0 my($err,$method_args) = _args_method_args($sort_method,\@args);
1103 0 ▶ return undef if ($err);
Branch: 1 branch
BranchTrueFalseTotal
if $err 0 0 0
1104 0 ▶ if (@args) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args) 0 0 0
1105 0 warn "ERROR: alternate sort error - invalid arguments: @args\n";
1106 0 return undef;
1107 }
1108 0 $args = $method_args;
1109 } else {
1110 0 warn "ERROR: alternate sort error - invalid definition\n";
1111 0 return undef;
1112 }
1113  
1114 } else {
1115 72 $args = $methods{$sort_method}{'altargs'};
1116 72 $sort_method = $methods{$sort_method}{'alt'};
1117 }
1118  
1119 72 my $func = $methods{$sort_method}{'function'};
1120 72 my $cmp = "_cmp_$func";
1121 72 $flag = &$cmp($x,$y,$args);
1122 72 ▶ return $flag if (! defined($flag));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $flag 0 72 72
1123 72 $sort_type = $methods{$sort_method}{'type'};
1124 }
1125 }
1126  
1127 # If it's reverse...
1128  
1129 51 ▶ if ($rev || $methods{$sort_method}{'reverse'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rev or $Sort::DataTypes::methods{$sort_method}{"reverse"}) 3 48 51
Condition66%2/3
$rev or $Sort::DataTypes::methods{$sort_method}{"reverse"}
l!l&&r!l&&!r
3048
MC/DC50%1/2
$rev or $Sort::DataTypes::methods{$sort_method}{"reverse"}
$rev $Sort::DataTypes::methods{$sort_method}{"reverse"}
Truth table66%2/3
A or B
A= $revB= $Sort::DataTypes::methods{$sort_method}{"reverse"}
ABresult
1X1
011
000
1130 3 $flag *= -1;
1131 }
1132  
1133 # Done
1134  
1135 51 return $flag;
1136 }
1137  
1138 ###############################################################################
1139  
1140 5 ▶sub _sort_partial {
Subroutine _sort_partial: called CC=3 SCAR=11.1
1141 5 my($rev,$method,@args) = @_;
1142  
1143 5 my($err,$list,$args,@extra) = _args_sort($method,@args);
1144 5 ▶ return undef if ($err);
Branch: 1 branch
BranchTrueFalseTotal
if $err 0 5 5
1145 5 ▶ return 1 if (! @$list);
Branch: 1 branch
BranchTrueFalseTotal
unless @$list 0 5 5
1146  
1147 # Sort the list.
1148  
1149 5 my @list;
1150 5 @list = sort { __cmp_partial($rev,$method,$a,$b,$args,@extra) } @$list;
1151  
1152 # Done
1153  
1154 5 @$list = @list;
1155 5 return 1;
1156 }
1157  
1158 0 ▶sub _cmp_partial {
Subroutine _cmp_partial: not called CC=2 SCAR=17.9
1159 0 my($rev,$method,@args) = @_;
1160  
1161 0 my($err,$x,$y,$args,@extra) = _args_cmp($method,@args);
1162 0 ▶ return undef if ($err);
Branch: 1 branch
BranchTrueFalseTotal
if $err 0 0 0
1163 0 return __cmp_partial($rev,$method,$x,$y,$args,@extra);
1164 }
1165  
1166 30 ▶sub __cmp_partial {
Subroutine __cmp_partial: called CC=31 SCAR=48.3
1167 30 my($rev,$method,$x,$y,$args,@extra) = @_;
1168  
1169 25 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
1170  
1171 # Compare the two elements
1172  
1173 30 my(@x,@y,$re);
1174 30 $re = $$args[0];
1175 30 @x = split($re,$x);
1176 30 @y = split($re,$y);
1177  
1178 30 my $flag = 0;
1179 30 my $sort_method;
1180  
1181 30 FIELD: foreach my $field_args (@extra) {
1182 41 my @field_args = @$field_args;
1183  
1184 # Get $n
1185  
1186 41 ▶ if (! @field_args) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@field_args) 0 41 41
1187 0 warn "ERROR: field args error - field number required\n";
1188 0 return undef;
1189 }
1190 41 my $n = shift(@field_args);
1191 41 ▶ if ($n !~ /^\d+$/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($n =~ /^\d+$/) 0 41 41
1192 0 warn "ERROR: field args error - field number must be integer: $n\n";
1193 0 return undef;
1194 }
1195  
1196 # Get $hash
1197  
1198 41 my $hash;
1199 41 ▶ if (@field_args && ref($field_args[0]) eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (@field_args and ref $field_args[0] eq 'HASH') { } 0 41 41
Condition66%2/3
@field_args and ref $field_args[0] eq "HASH"
!ll&&!rl&&r
11300
MC/DC0%0/2
@field_args and ref $field_args[0] eq "HASH"
@field_args ref $field_args[0] eq "HASH"
Truth table66%2/3
A and B
A= @field_argsB= ref $field_args[0] eq "HASH"
ABresult
0X0
100
111
1200 0 $hash = shift(@field_args);
1201 } else {
1202 41 $hash = undef;
1203 }
1204  
1205 # Get the Nth fields (and handle the undef cases)
1206  
1207 41 my($a,$b);
1208 41 ▶ if (@x < $n || ! defined $x[$n-1] || $x[$n-1] eq '') {
Branch: 2 branches
BranchTrueFalseTotal
if (@x < $n or not defined $x[$n - 1] or $x[$n - 1] eq '') { } 0 41 41
elsif (@y < $n or not defined $y[$n - 1] or $y[$n - 1] eq '') { } 0 41 41
Condition33%2/6
@x < $n or not defined $x[$n - 1] or $x[$n - 1] eq ""
l!l&&r!l&&!r
0041
@x < $n or not defined $x[$n - 1]
l!l&&r!l&&!r
0041
MC/DC0%0/3
@x < $n or not defined $x[$n - 1] or $x[$n - 1] eq ""
@x < $n not defined $x[$n - 1] $x[$n - 1] eq ""
Truth table25%1/4
A or not(B) or C
A= @x < $nB= not defined $x[$n - 1]C= $x[$n - 1] eq ""
ABCresult
1XX1
01X1
0011
0000
1209 0 ▶ if (@y < $n || ! defined $y[$n-1] || $y[$n-1] eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if (@y < $n or not defined $y[$n - 1] or $y[$n - 1] eq '') { } 0 0 0
Condition0%0/6
@y < $n or not defined $y[$n - 1] or $y[$n - 1] eq ""
l!l&&r!l&&!r
000
@y < $n or not defined $y[$n - 1]
l!l&&r!l&&!r
000
MC/DC0%0/3
@y < $n or not defined $y[$n - 1] or $y[$n - 1] eq ""
@y < $n not defined $y[$n - 1] $y[$n - 1] eq ""
Truth table0%0/4
A or not(B) or C
A= @y < $nB= not defined $y[$n - 1]C= $y[$n - 1] eq ""
ABCresult
1XX1
01X1
0011
0000
1210 0 $flag = 0;
1211 0 next FIELD;
1212 } else {
1213 0 $flag = -1;
1214 0 last FIELD;
1215 }
1216 ▶ } elsif (@y < $n || ! defined $y[$n-1] || $y[$n-1] eq '') {
Condition33%2/6
@y < $n or not defined $y[$n - 1] or $y[$n - 1] eq ""
l!l&&r!l&&!r
0041
@y < $n or not defined $y[$n - 1]
l!l&&r!l&&!r
0041
MC/DC0%0/3
@y < $n or not defined $y[$n - 1] or $y[$n - 1] eq ""
@y < $n not defined $y[$n - 1] $y[$n - 1] eq ""
Truth table25%1/4
A or not(B) or C
A= @y < $nB= not defined $y[$n - 1]C= $y[$n - 1] eq ""
ABCresult
1XX1
01X1
0011
0000
1217 0 $flag = 1;
1218 0 last FIELD;
1219 }
1220  
1221 41 $a = $x[$n-1];
1222 41 $b = $y[$n-1];
1223  
1224 # Handle $hash (if defined)
1225  
1226 41 ▶ if (defined $hash) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $hash) 0 41 41
1227 0 ▶ if (! exists $$hash{$a}) {
Branch: 2 branches
BranchTrueFalseTotal
if (not exists $hash->{$a}) { } 0 0 0
elsif (not exists $hash->{$b}) { } 0 0 0
1228 0 ▶ if (! exists $$hash{$b}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not exists $hash->{$b}) { } 0 0 0
1229 0 $flag = 0;
1230 0 next FIELD;
1231 } else {
1232 0 $flag = -1;
1233 0 last FIELD;
1234 }
1235 } elsif (! exists $$hash{$b}) {
1236 0 $flag = 1;
1237 0 last FIELD;
1238 }
1239 0 $a = $$hash{$a};
1240 0 $b = $$hash{$b};
1241 }
1242  
1243 # Compare two fields
1244  
1245 41 $sort_method = 'partial';
1246 41 my $sort_type = 'partial';
1247  
1248 41 ▶ METHOD: while (! $flag && (@field_args || $sort_type ne 'unambiguous')) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $flag and @field_args || $sort_type ne "unambiguous") 41 41 82
Condition100%6/6
not $flag and @field_args || $sort_type ne "unambiguous"
!ll&&!rl&&r
301141
@field_args or $sort_type ne "unambiguous"
l!l&&r!l&&!r
301111
MC/DC100%3/3
not $flag and @field_args || $sort_type ne "unambiguous"
not $flag @field_args $sort_type ne "unambiguous"
Truth table100%4/4
not(A) and B or C
A= not $flagB= @field_argsC= $sort_type ne "unambiguous"
ABCresult
0XX0
1000
11X1
1011
1249 41 ▶ if (@field_args) {
Branch: 1 branch
BranchTrueFalseTotal
if (@field_args) { } 30 11 41
1250 30 ▶ if (ref($field_args[0]) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $field_args[0] eq 'ARRAY') { } 30 0 30
1251 30 my(@args);
1252 30 ($sort_method,@args) = @{ shift(@field_args) };
1253 30 ▶ if (! exists $methods{$sort_method}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $Sort::DataTypes::methods{$sort_method}) 0 30 30
1254 0 warn "ERROR: alternate sort error - invalid method: $sort_method\n";
1255 0 return undef;
1256 }
1257 30 my($err,$method_args) = _args_method_args($sort_method,\@args);
1258 30 ▶ return undef if ($err);
Branch: 1 branch
BranchTrueFalseTotal
if $err 0 30 30
1259 30 ▶ if (@args) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args) 0 30 30
1260 0 warn "ERROR: alternate sort error - invalid arguments: @args\n";
1261 0 return undef;
1262 }
1263 30 $args = $method_args;
1264 } else {
1265 0 warn "ERROR: alternate sort error - invalid definition\n";
1266 0 return undef;
1267 }
1268  
1269 } else {
1270 11 $args = $methods{$sort_method}{'altargs'};
1271 11 $sort_method = $methods{$sort_method}{'alt'};
1272 }
1273  
1274 41 my $func = $methods{$sort_method}{'function'};
1275 41 my $cmp = "_cmp_$func";
1276 41 $flag = &$cmp($a,$b,$args);
1277 41 ▶ return $flag if (! defined($flag));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $flag 0 41 41
1278 41 $sort_type = $methods{$sort_method}{'type'};
1279 }
1280  
1281 41 ▶ last FIELD if ($flag);
Branch: 1 branch
BranchTrueFalseTotal
if $flag 30 11 41
1282 }
1283  
1284 # If it's reverse...
1285  
1286 30 ▶ if ($rev || $methods{$sort_method}{'reverse'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rev or $Sort::DataTypes::methods{$sort_method}{"reverse"}) 0 30 30
Condition33%1/3
$rev or $Sort::DataTypes::methods{$sort_method}{"reverse"}
l!l&&r!l&&!r
0030
MC/DC0%0/2
$rev or $Sort::DataTypes::methods{$sort_method}{"reverse"}
$rev $Sort::DataTypes::methods{$sort_method}{"reverse"}
Truth table33%1/3
A or B
A= $revB= $Sort::DataTypes::methods{$sort_method}{"reverse"}
ABresult
1X1
011
000
1287 0 $flag *= -1;
1288 }
1289  
1290 # Done
1291  
1292 30 return $flag;
1293 }
1294  
1295 ###############################################################################
1296  
1297 49 ▶sub _args_sort {
Subroutine _args_sort: called CC=11 SCAR=27.9
1298 49 my(@args) = @_;
1299 49 my(@ret,$err,$method,$listref,$method_args,$hash);
1300  
1301 # Method
1302  
1303 49 ▶ if (! @args) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@args) 0 49 49
1304 0 warn "ERROR: sort argument error - method required\n";
1305 0 return (1);
1306 }
1307 49 $method = shift(@args);
1308 49 ▶ if (! exists $methods{$method}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $Sort::DataTypes::methods{$method}) 0 49 49
1309 0 warn "ERROR: sort argument error - invalid method: $method\n";
1310 0 return (1);
1311 }
1312  
1313 # Listref
1314  
1315 49 ▶ if (! @args) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@args) 0 49 49
1316 0 warn "ERROR: sort argument error - listref expected\n";
1317 0 return (1);
1318 }
1319  
1320 49 ▶ if (ref($args[0]) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $args[0] eq 'ARRAY') { } 49 0 49
1321 49 $listref = shift(@args);
1322 } else {
1323 0 warn "ERROR: sort argument error - listref expected\n";
1324 0 return (1);
1325 }
1326 49 push(@ret,$listref);
1327  
1328 # Method arguments
1329  
1330 49 ($err,$method_args) = _args_method_args($method,\@args);
1331 49 ▶ return (1) if ($err);
Branch: 1 branch
BranchTrueFalseTotal
if $err 0 49 49
1332 49 push(@ret,$method_args);
1333  
1334 # Hash
1335  
1336 49 ▶ if ($method ne 'partial') {
Branch: 1 branch
BranchTrueFalseTotal
if ($method ne "partial") 44 5 49
1337 44 ▶ if (@args && ref($args[0]) eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (@args and ref $args[0] eq 'HASH') { } 2 42 44
Condition100%3/3
@args and ref $args[0] eq "HASH"
!ll&&!rl&&r
4022
MC/DC100%2/2
@args and ref $args[0] eq "HASH"
@args ref $args[0] eq "HASH"
Truth table100%3/3
A and B
A= @argsB= ref $args[0] eq "HASH"
ABresult
0X0
100
111
1338 2 $hash = shift(@args);
1339 } else {
1340 42 $hash = undef;
1341 }
1342 44 push(@ret,$hash);
1343 }
1344  
1345 # Extra
1346  
1347 49 ▶ if ($method eq 'unambiguous' && @args) {
Branch: 1 branch
BranchTrueFalseTotal
if ($method eq "unambiguous" and @args) 0 49 49
Condition33%1/3
$method eq "unambiguous" and @args
!ll&&!rl&&r
4900
MC/DC0%0/2
$method eq "unambiguous" and @args
$method eq "unambiguous" @args
Truth table33%1/3
A and B
A= $method eq "unambiguous"B= @args
ABresult
0X0
100
111
1348 0 warn "ERROR: sort argument error - unexpected arguments: @args\n";
1349 0 return (1);
1350 }
1351  
1352 49 return (0,@ret,@args);
1353 }
1354  
1355 # ($method,$x,$y,@method_args,@extra)
1356 #
1357 6 ▶sub _args_cmp {
Subroutine _args_cmp: called CC=7 SCAR=23.8
1358 6 my(@args) = @_;
1359 6 my(@ret,$err,$method,$x,$y,$method_args,$hash);
1360  
1361 # Method
1362  
1363 6 ▶ if (! @args) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@args) 0 6 6
1364 0 warn "ERROR: cmp argument error - method required\n";
1365 0 return (1);
1366 }
1367 6 $method = shift(@args);
1368 6 ▶ if (! exists $methods{$method}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $Sort::DataTypes::methods{$method}) 0 6 6
1369 0 warn "ERROR: cmp argument error - invalid method: $method\n";
1370 0 return (1);
1371 }
1372  
1373 # X,Y
1374  
1375 6 ▶ if (@args < 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args < 2) 0 6 6
1376 0 warn "ERROR: cmp argument error - two elements expected\n";
1377 0 return (1);
1378 }
1379 6 $x = shift(@args);
1380 6 $y = shift(@args);
1381 6 push(@ret,$x,$y);
1382  
1383 # Method arguments
1384  
1385 6 ($err,$method_args) = _args_method_args($method,\@args);
1386 6 ▶ return (1) if ($err);
Branch: 1 branch
BranchTrueFalseTotal
if $err 0 6 6
1387 6 push(@ret,$method_args);
1388  
1389 # Extra
1390  
1391 6 ▶ if ($method eq 'unambiguous' && @args) {
Branch: 1 branch
BranchTrueFalseTotal
if ($method eq "unambiguous" and @args) 0 6 6
Condition33%1/3
$method eq "unambiguous" and @args
!ll&&!rl&&r
600
MC/DC0%0/2
$method eq "unambiguous" and @args
$method eq "unambiguous" @args
Truth table33%1/3
A and B
A= $method eq "unambiguous"B= @args
ABresult
0X0
100
111
1392 0 warn "ERROR: cmp argument error - unexpected arguments: @args\n";
1393 0 return (1);
1394 }
1395  
1396 6 return (0,@ret,@args);
1397 }
1398  
1399 90 ▶sub _args_method_args {
Subroutine _args_method_args: called CC=17 SCAR=29.9
1400 90 my($method,$args) = @_;
1401 90 my @method_args;
1402  
1403 90 my @expected = @{ $methods{$method}{'args'} };
1404  
1405 90 foreach my $expected (@expected) {
1406 47 my $type = $$expected{'type'};
1407  
1408 47 ▶ if ($type eq 'member') {
Branch: 4 branches
BranchTrueFalseTotal
if ($type eq 'member') { } 18 29 47
elsif ($type eq 'regexp') { } 23 6 29
elsif ($type eq 'function') { } 3 3 6
elsif ($type eq 'string') { } 3 0 3
1409 18 my %vals = map { $_,1 } @{ $$expected{'values'} };
1410 18 ▶ if (@$args && exists $vals{ $$args[0] }) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$args and exists $vals{$args->[0]}) { } 15 3 18
Condition100%3/3
@$args and exists $vals{$args->[0]}
!ll&&!rl&&r
1215
MC/DC100%2/2
@$args and exists $vals{$args->[0]}
@$args exists $vals{$args->[0]}
Truth table100%3/3
A and B
A= @$argsB= exists $vals{$args->[0]}
ABresult
0X0
100
111
1411 15 push(@method_args,shift(@$args));
1412 } else {
1413 3 push(@method_args,$$expected{'default'});
1414 }
1415  
1416 } elsif ($type eq 'regexp') {
1417 23 ▶ if (@$args) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$args) { } 22 1 23
1418 22 ▶ if (ref($$args[0]) eq 'Regexp') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $args->[0] eq 'Regexp') { } 7 15 22
elsif (not ref $args->[0]) { } 14 1 15
1419 7 push(@method_args,shift(@$args));
1420 } elsif (! ref($$args[0])) {
1421 14 my $re = shift(@$args);
1422 14 push(@method_args,qr/$re/);
1423 } else {
1424 1 my $re = $$expected{'default'};
1425 1 push(@method_args,qr/$re/);
1426 }
1427 } else {
1428 1 my $re = $$expected{'default'};
1429 1 push(@method_args,qr/$re/);
1430 }
1431  
1432 } elsif ($type eq 'function') {
1433 3 ▶ if (@$args && (ref($$args[0]) eq 'CODE' || ! ref($$args[0]))) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$args and ref $args->[0] eq 'CODE' || !ref($args->[0])) { } 3 0 3
Condition50%3/6
@$args and ref $args->[0] eq "CODE" || !ref($args->[0])
!ll&&!rl&&r
003
ref $args->[0] eq "CODE" or not ref $args->[0]
l!l&&r!l&&!r
120
MC/DC0%0/3
@$args and ref $args->[0] eq "CODE" || !ref($args->[0])
@$args ref $args->[0] eq "CODE" not ref $args->[0]
Truth table50%2/4
A and B or not(C)
A= @$argsB= ref $args->[0] eq "CODE"C= not ref $args->[0]
ABCresult
0XX0
1000
11X1
1011
1434 3 push(@method_args,shift(@$args));
1435 } else {
1436 0 die "ERROR: invalid argument - function required\n";
1437 }
1438  
1439 } elsif ($type eq 'string') {
1440 3 ▶ if (@$args && ! ref($$args[0])) {
Branch: 2 branches
BranchTrueFalseTotal
if (@$args and not ref $args->[0]) { } 3 0 3
elsif (exists $expected->{'default'}) { } 0 0 0
Condition33%1/3
@$args and not ref $args->[0]
!ll&&!rl&&r
003
MC/DC0%0/2
@$args and not ref $args->[0]
@$args not ref $args->[0]
Truth table33%1/3
A and not(B)
A= @$argsB= not ref $args->[0]
ABresult
0X0
100
111
1441 3 push(@method_args,shift(@$args));
1442 } elsif (exists $$expected{'default'}) {
1443 0 push(@method_args,$$expected{'default'});
1444 } else {
1445 0 die "ERROR: invalid argument - string required\n";
1446 }
1447  
1448 } else {
1449 0 die "ERROR: invalid argument descriptor: $type\n";
1450 }
1451 }
1452  
1453 90 return (0,\@method_args);
1454 }
1455  
1456 25 1;
1457 # Local Variables:
1458 # mode: cperl
1459 # indent-tabs-mode: nil
1460 # cperl-indent-level: 3
1461 # cperl-continued-statement-offset: 2
1462 # cperl-continued-brace-offset: 0
1463 # cperl-brace-offset: 0
1464 # cperl-brace-imaginary-offset: 0
1465 # cperl-label-offset: -2
1466 # End:
↑ Summary