blib/lib/Alien/Util.pm

filter: Statementstmt 91.6% 22 / 24 Branchbran 50.0% 5 / 10 Conditioncond 44.4% 4 / 9 MC/DCmcdc 33.3% 2 / 6 Subroutinesub 100% 4 / 4 Podpod 100% 1 / 1 totaltotal 70.3% 38 / 54 CC 9 SCAR 23.5
CC
9
Cov
72%
version_cmp
13.7
BEGIN
1.0
BEGIN
1.0
CRAP 10.5
« blib/lib/Alien/Build/MM.pm ↑ Summary blib/lib/Alien/Base/Wrapper.pm »
1 package Alien::Util;
2  
3 18 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 18 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 18 ▶use Exporter qw( import );
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 # ABSTRACT: Alien Utilities used at build and runtime
8 18 our $VERSION = '2.88'; # VERSION
9  
10  
11 18 our @EXPORT_OK = qw( version_cmp );
12  
13  
14 # Sort::Versions isn't quite the same algorithm because it differs in
15 # behaviour with leading zeroes.
16 # See also https://dev.gentoo.org/~mgorny/pkg-config-spec.html#version-comparison
17 9 ▶sub version_cmp {
Subroutine version_cmp: called CC=9 SCAR=26.2
Pod documented
18 9 my @x = (shift =~ m/([0-9]+|[a-z]+)/ig);
19 9 my @y = (shift =~ m/([0-9]+|[a-z]+)/ig);
20  
21 9 ▶ while(@x and @y) {
Branch: 1 branch
BranchTrueFalseTotal
if (@x and @y) 21 3 24
Condition100%3/3
@x and @y
!ll&&!rl&&r
2121
MC/DC100%2/2
@x and @y
@x @y
Truth table100%3/3
A and B
A= @xB= @y
ABresult
0X0
100
111
22 21 my $x = shift @x; my $x_isnum = $x =~ m/[0-9]/;
23 21 my $y = shift @y; my $y_isnum = $y =~ m/[0-9]/;
24  
25 21 ▶ if($x_isnum and $y_isnum) {
Branch: 2 branches
BranchTrueFalseTotal
if ($x_isnum and $y_isnum) { } 21 0 21
elsif (not $x_isnum || $y_isnum) { } 0 0 0
Condition33%1/3
$x_isnum and $y_isnum
!ll&&!rl&&r
0021
MC/DC0%0/2
$x_isnum and $y_isnum
$x_isnum $y_isnum
Truth table33%1/3
A and B
A= $x_isnumB= $y_isnum
ABresult
0X0
100
111
26 # Numerical comparison
27 21 ▶ return $x <=> $y if $x != $y;
Branch: 1 branch
BranchTrueFalseTotal
if $x != $y 6 15 21
28 }
29 ▶ elsif(!$x_isnum && !$y_isnum) {
Condition0%0/3
$x_isnum || $y_isnum
l!l&&r!l&&!r
000
MC/DC0%0/2
$x_isnum || $y_isnum
$x_isnum $y_isnum
Truth table0%0/3
A || B
A= $x_isnumB= $y_isnum
ABresult
1X1
011
000
30 # Alphabetic comparison
31 0 ▶ return $x cmp $y if $x ne $y;
Branch: 1 branch
BranchTrueFalseTotal
if $x ne $y 0 0 0
32 }
33 else {
34 # Of differing types, the numeric one is newer
35 0 return $x_isnum - $y_isnum;
36 }
37 }
38  
39 # Equal so far; the longer is newer
40 3 return @x <=> @y;
41 }
42  
43 18 1;
44  
45 __END__
« blib/lib/Alien/Build/MM.pm ↑ Summary blib/lib/Alien/Base/Wrapper.pm »