blib/lib/String/ZeroButTrue.pm

filter: Statementstmt 100% 21 / 21 Branchbran 100% 2 / 2 Conditioncond 100% 9 / 9 MC/DCmcdc 100% 4 / 4 Subroutinesub 100% 7 / 7 Podpod 100% 4 / 4 totaltotal 100% 47 / 47 CC 5 SCAR 10.4
CC
5
Cov
100%
is_zero_but_true
5.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.8
↑ Summary
1 package String::ZeroButTrue;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 $String::ZeroButTrue::VERSION = '0.2';
7  
8 2 ▶use base 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 @String::ZeroButTrue::EXPORT = qw(get_zero_but_true is_zero_but_true);
10 2 @String::ZeroButTrue::EXPORT_OK = qw(get_zero_but_true_uc get_zero_but_true_phrase);
11 2 %String::ZeroButTrue::EXPORT_TAGS = (
12 'all' => [@String::ZeroButTrue::EXPORT, @String::ZeroButTrue::EXPORT_OK],
13 );
14  
15 1 ▶sub get_zero_but_true {
Subroutine get_zero_but_true: called CC=1 SCAR=0.0
Pod documented
16 1 return '0e0';
17 }
18  
19 1 ▶sub get_zero_but_true_uc {
Subroutine get_zero_but_true_uc: called CC=1 SCAR=0.0
Pod documented
20 1 return '0E0';
21 }
22  
23 1 ▶sub get_zero_but_true_phrase {
Subroutine get_zero_but_true_phrase: called CC=1 SCAR=0.0
Pod documented
24 1 return '0 but true';
25 }
26  
27 9 ▶sub is_zero_but_true {
Subroutine is_zero_but_true: called CC=5 SCAR=16.1
Pod documented
28 9 my $string = shift;
29 # We have to do a string eq because $string && $string == 0 it true when its a string being compared numerically:
30 # perl -Mstrict -we 'if ("hello world" == 0) { print "yes it is 0\n" }
31 # no warnings 'numeric'; # string might *be* a string == Argument "$string" isn't numeric in numeric eq (==) at ...
32 # return 1 if defined $string && $string && $string == 0;
33
34 9 $string =~ tr/A-Z/a-z/;
35 9 ▶ return 1 if defined $string && $string && ($string eq '0e0' || $string eq '0 but true');
Branch: 1 branch
BranchTrueFalseTotal
if defined $string and $string and $string eq "0e0" || $string eq "0 but true" 4 5 9
Condition100%9/9
defined $string and $string and $string eq "0e0" || $string eq "0 but true"
!ll&&!rl&&r
414
defined $string and $string
!ll&&!rl&&r
225
$string eq "0e0" or $string eq "0 but true"
l!l&&r!l&&!r
221
MC/DC100%4/4
defined $string and $string and $string eq "0e0" || $string eq "0 but true"
defined $string $string $string eq "0e0" $string eq "0 but true"
Truth table100%5/5
A and B and C or D
A= defined $stringB= $stringC= $string eq "0e0"D= $string eq "0 but true"
ABCDresult
0XXX0
10XX0
11000
111X1
11011
36 5 return;
37 }
38  
39 2 1;
40  
41 __END__
↑ Summary