lib/Lingy/Lang/String.pm

filter: Statementstmt 47.0% 16 / 34 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 45.4% 5 / 11 Podpod 0.0% 0 / 5 totaltotal 29.5% 21 / 71 CC 7 SCAR 27.9
CC
7
Cov
33%
substring
42.0
_to_seq
6.0
join
2.0
CRAP 16.3
« lib/Lingy/Common.pm ↑ Summary lib/Lingy/Lang/Boolean.pm »
1 1 ▶use strict; use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
2 package Lingy::Lang::String;
3  
4 1 ▶use Lingy::Common;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use base SCALARTYPE;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶use overload cmp => \&comp_pair;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 # TODO define lingy.string/join
10 sub join {
11 string(
12 0 CORE::join ${Lingy::Lang::RT::str($_[0])},
13 0 ▶ map ${Lingy::Lang::RT::str($_)}, @{$_[1]}
Subroutine join: not called CC=1 SCAR=6.9
Pod undocumented
14 );
15 }
16  
17 sub replaceAll {
18 0 ▶ my ($str, $pat, $rep) = @_;
Subroutine replaceAll: not called CC=1 SCAR=6.9
Pod undocumented
19 0 $str =~ s/\Q$pat\E/$rep/g;
20 0 string($str);
21 }
22  
23 sub substring {
24 0 ▶ my ($string, $offset1, $offset2) = @_;
Subroutine substring: not called CC=6 SCAR=37.4
Pod undocumented
25 0 my $length = length $string;
26 0 ▶ $offset2 //= NUMBER->new($length);
Condition0%0/3
$offset2 //= "Lingy::Lang::Number"->new($length)
l!l&&r!l&&!r
000
MC/DC0%0/2
$offset2 //= "Lingy::Lang::Number"->new($length)
$offset2 "Lingy::Lang::Number"->new($length)
Truth table0%0/3
A //= B
A= $offset2B= "Lingy::Lang::Number"->new($length)
ABresult
1X1
011
000
27 0 ▶ err "Begin index out of range '%d' for string length '%d'",
Branch: 1 branch
BranchTrueFalseTotal
if $offset1 < 0 or $offset1 > $length 0 0 0
Condition0%0/3
$offset1 < 0 or $offset1 > $length
l!l&&r!l&&!r
000
MC/DC0%0/2
$offset1 < 0 or $offset1 > $length
$offset1 < 0 $offset1 > $length
Truth table0%0/3
A or B
A= $offset1 < 0B= $offset1 > $length
ABresult
1X1
011
000
28 $offset1, $length
29 if $offset1 < 0 or $offset1 > $length;
30 0 ▶ err "End index out of range '%d' for string length '%d'",
Branch: 1 branch
BranchTrueFalseTotal
if $offset2 < $offset1 or $offset2 > $length 0 0 0
Condition0%0/3
$offset2 < $offset1 or $offset2 > $length
l!l&&r!l&&!r
000
MC/DC0%0/2
$offset2 < $offset1 or $offset2 > $length
$offset2 < $offset1 $offset2 > $length
Truth table0%0/3
A or B
A= $offset2 < $offset1B= $offset2 > $length
ABresult
1X1
011
000
31 $offset2, $length
32 if $offset2 < $offset1 or $offset2 > $length;
33 0 string(substr("$string", $offset1, $offset2 - $offset1))
34 }
35  
36 sub toLowerCase {
37 0 ▶ string(lc $_[0]);
Subroutine toLowerCase: not called CC=1 SCAR=6.9
Pod undocumented
38 }
39  
40 sub toUpperCase {
41 0 ▶ string(uc $_[0]);
Subroutine toUpperCase: not called CC=1 SCAR=6.9
Pod undocumented
42 }
43  
44 sub _to_seq {
45 0 ▶ my ($str) = @_;
Subroutine _to_seq: not called CC=2 SCAR=17.9
46 0 ▶ return nil unless length $str;
Branch: 1 branch
BranchTrueFalseTotal
unless length $str 0 0 0
47 0 list([
48 map CHARACTER->read("\\$_"), split //, $$str
49 ]);
50 }
51  
52 1 1;
« lib/Lingy/Common.pm ↑ Summary lib/Lingy/Lang/Boolean.pm »