File Coverage

lib/Perlmazing/Perlmazing/Precompile/numeric.pm
Criterion Covered Total %
statement 20 35 57.1
branch 14 32 43.7
condition 10 18 55.5
subroutine 2 2 100.0
pod n/a
total 46 87 52.8


line stmt bran cond sub pod time code
1 50     50   438 use Perlmazing;
  50         123  
  50         275  
2            
3             sub main ($$) {
4 239     239   647 my ($aa, $bb) = ($_[0], $_[1]);
5 239 50 33     526 if (is_number $aa and is_number $bb) {
    50 33        
    50          
    50          
    0          
    0          
6 0         0 my $r = to_number($aa) <=> to_number($bb);
7 0 0       0 return $r if $r;
8 0         0 $aa cmp $bb;
9             } elsif (is_number $aa) {
10 0         0 -1;
11             } elsif (is_number $bb) {
12 0         0 1;
13             } elsif (defined($aa) and defined($bb)) {
14 239 100 100     658 if ($aa =~ /\d/ and $bb =~ /\d/) {
15 4         20 my @split_a = split /(\d+)/, $aa;
16 4         13 my @split_b = split /(\d+)/, $bb;
17 4         7 my $current_sort = 0;
18 4         7 my $cmp_sort = '';
19 4         6 while (1) {
20 7         9 my $break = 1;
21 7 50 33     27 last unless @split_a and @split_b;
22 7         16 my ($aa, $bb) = (shift(@split_a), shift(@split_b));
23 7 100 66     43 if (is_number $aa and is_number $bb) {
    50          
    50          
24 3         7 $current_sort = $aa <=> $bb;
25 3 50       8 unless ($current_sort) {
26 0         0 $current_sort = $aa cmp $bb;
27 0 0       0 $cmp_sort = $current_sort unless $cmp_sort;
28 0         0 $break = 0;
29             }
30             } elsif (is_number $aa) {
31 0         0 $current_sort = -1;
32             } elsif (is_number $bb) {
33 0         0 $current_sort = 1;
34             } else {
35 4         9 $current_sort = $aa cmp $bb;
36             }
37 7 100 66     28 return $current_sort if $current_sort and $break;
38             }
39 0 0       0 return $cmp_sort if $cmp_sort;
40 0         0 $current_sort;
41             } else {
42 235         542 $aa cmp $bb;
43             }
44             } elsif (defined $aa) {
45 0           1;
46             } elsif (defined $bb) {
47 0           -1;
48             } else {
49 0           0;
50             }
51             }
52