blib/lib/Acme/MyPeek.pm

filter: Statementstmt 100% 46 / 46 Branchbran 80.0% 8 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod 0.0% 0 / 5 totaltotal 90.1% 64 / 71 SCAR 20.8
CC
8
Cov
96%
highval
8.0
BEGIN
1.0
BEGIN
1.0
CRAP 8.0
↑ Summary
1 package Acme::MyPeek;
2 1 $Acme::MyPeek::VERSION = '0.06';
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use B qw(svref_2object class);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 require Exporter;
9  
10 1 our @ISA = qw(Exporter);
11 1 our @EXPORT = qw(hi hd dt lv);
12 1 our @EXPORT_OK = qw();
13  
14 1 my $last_val;
15  
16 126 ▶sub hi { highval( sub{ $_[0] eq sprintf('%u', $_[0]) }); }
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine hi: called CC=1 SCAR=0.0
Pod undocumented
17 108 ▶sub hd { highval( sub{ sprintf('%.f', $_[0]) ne sprintf('%.f', $_[0] - 1) }); }
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine hd: called CC=1 SCAR=0.0
Pod undocumented
18 3 ▶sub dt { class(svref_2object(\$_[0])); }
Subroutine dt: called CC=1 SCAR=0.0
Pod undocumented
19 2 ▶sub lv { $last_val; }
Subroutine lv: called CC=1 SCAR=0.0
Pod undocumented
20  
21 sub highval {
22 2 ▶ my ($ok) = @_;
Subroutine highval: called CC=8 SCAR=20.8
Pod undocumented
23  
24 2 my $x = 1;
25 2 my $f = 1;
26  
27 2 for (1..100) {
28 36 my $y = $x * 10;
29  
30 36 ▶ unless ($ok->($y)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (&$ok($y)) 2 34 36
31 2 $f = 0;
32 2 last;
33 }
34  
35 34 $x = $y;
36 }
37  
38 2 $last_val = $x;
39  
40 2 ▶ return -1 if $f;
Branch: 1 branch
BranchTrueFalseTotal
if $f 0 2 2
41  
42 2 my $r = $x;
43  
44 2 for (1..1000) {
45 198 my $y = $x + $r;
46  
47 198 ▶ unless ($ok->($y)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (&$ok($y)) 36 162 198
48 36 ▶ if ($r <= 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($r <= 1) 2 34 36
49 2 $r = 0;
50 2 last;
51 }
52  
53 34 $r /= 10;
54 34 next;
55 }
56  
57 162 $x += $r;
58 }
59  
60 2 $last_val = $x;
61  
62 2 ▶ return -2 if $r;
Branch: 1 branch
BranchTrueFalseTotal
if $r 0 2 2
63  
64 2 return $x
65 }
66  
67 1 1;
68  
69 __END__
↑ Summary