blib/lib/Return/DataButBool.pm

filter: Statementstmt 100% 35 / 35 Branchbran 100% 6 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 15 / 15 Podpod 100% 3 / 3 totaltotal 100% 59 / 59 CC 4 SCAR 2.9
CC
4
Cov
100%
data_but_true
2.0
data_but_false
2.0
_get_num_from
2.0
CRAP 1.3
↑ Summary
1 package Return::DataButBool;
2  
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use version; our $VERSION = qv('0.0.3');
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 ▶use base 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 our @EXPORT = qw(zero_but_true data_but_true data_but_false);
10  
11 # bring in the big guns
12 2 ▶use Contextual::Return;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 1 ▶sub zero_but_true {
Subroutine zero_but_true: called CC=1 SCAR=0.0
Pod documented
15 1 return '0e0';
16 }
17  
18 3 ▶sub data_but_true {
Subroutine data_but_true: called CC=2 SCAR=6.9
Pod documented
19 3 my $num = _get_num_from( shift() );
20 3 my $str = shift();
21 3 ▶ $str = $num if !defined $str;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $str 1 2 3
22
23 return (
24 2 ▶ BOOL { 1; }
Subroutine __ANON__: called CC=1 SCAR=0.0
25 2 ▶ NUM { $num }
Subroutine __ANON__: called CC=1 SCAR=0.0
26 3 ▶ STR { $str }
Subroutine __ANON__: called CC=1 SCAR=0.0
27 3 );
28 }
29  
30 3 ▶sub data_but_false {
Subroutine data_but_false: called CC=2 SCAR=6.9
Pod documented
31 3 my $num = _get_num_from( shift() );
32 3 my $str = shift();
33 3 ▶ $str = $num if !defined $str;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $str 1 2 3
34  
35 return (
36 2 ▶ BOOL { 0; }
Subroutine __ANON__: called CC=1 SCAR=0.0
37 2 ▶ NUM { $num }
Subroutine __ANON__: called CC=1 SCAR=0.0
38 3 ▶ STR { $str }
Subroutine __ANON__: called CC=1 SCAR=0.0
39 3 );
40 }
41  
42 # out in external num() func or something?
43 14 ▶sub _get_num_from {
Subroutine _get_num_from: called CC=2 SCAR=6.9
44 14 my ($num) = @_;
45 14 ▶ return $num =~ m{ \A ([-+]? \d+ (?: [.] \d+ )?) \z }xms ? $1 : int($num);
Branch: 1 branch
BranchTrueFalseTotal
$num =~ / \A ([-+]? \d+ (?: [.] \d+ )?) \z /msx ? : 12 2 14
46 }
47  
48 2 1;
49  
50 __END__
↑ Summary