Karel/Util.pm

filter: Statementstmt 100% 19 / 19 Branchbran 100% 4 / 4 Conditioncond 100% 8 / 8 MC/DCmcdc 100% 5 / 5 Subroutinesub 100% 6 / 6 Podpod 100% 2 / 2 totaltotal 100% 44 / 44 CC 7 SCAR 15.0
CC
7
Cov
100%
m_to_n
7.0
BEGIN
1.0
BEGIN
1.0
CRAP 4.5
« Karel/Robot.pm ↑ Summary Karel/Parser.pm »
1 package Karel::Util;
2  
3 =head1 NAME
4  
5 Karel::Util
6  
7 =head1 DESCRITPTION
8  
9 Helper functions for other packages.
10  
11 =head1 FUNCTIONS
12  
13 =over 4
14  
15 =item m_to_n($i, $m, $n)
16  
17 Checks whether the integer C<$i> lies between C<$m> and C<$n>
18 inclusive.
19  
20 =item positive_int($i)
21  
22 Checks whether C<$i> is a positive integer, i.e. C<m_to_n($i, 1, $i)>.
23  
24 =back
25  
26 =cut
27  
28 10 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
29 10 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
30  
31 10 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
32 10 ▶use parent qw( Exporter );
Subroutine BEGIN: called CC=1 SCAR=0.0
33 10 our @EXPORT_OK = qw{ positive_int m_to_n };
34  
35  
36 3870 ▶sub m_to_n {
Subroutine m_to_n: called CC=7 SCAR=19.5
Pod documented
37 3870 my ($i, $m, $n) = @_;
38 defined && /^[0-9]+$/
39 or croak +($_ // 'undef') . ' should be non negative integer'
40 3870 ▶ for $i, $m, $n;
Branch: 1 branch
BranchTrueFalseTotal
defined $_ and /^[0-9]+$/ or croak(($_ // "undef") . ' should be non negative integer') 11598 4 11602
Condition100%5/5
defined $_ and /^[0-9]+$/
!ll&&!rl&&r
2211598
$_ // "undef"
l!l
22
MC/DC100%2/2
defined $_ and /^[0-9]+$/
defined $_ /^[0-9]+$/
MC/DC100%1/1
$_ // "undef"
$_
Truth table100%3/3
A and B
A= defined $_B= /^[0-9]+$/
ABresult
0X0
100
111
Truth table100%2/2
A
A= $_
Aresult
11
00
41 3866 ▶ $m <= $i && $i <= $n or croak "$i not between $m and $n";
Branch: 1 branch
BranchTrueFalseTotal
$m <= $i and $i <= $n or croak("$i not between $m and $n") 3860 6 3866
Condition100%3/3
$m <= $i and $i <= $n
!ll&&!rl&&r
423860
MC/DC100%2/2
$m <= $i and $i <= $n
$m <= $i $i <= $n
Truth table100%3/3
A and B
A= $m <= $iB= $i <= $n
ABresult
0X0
100
111
42 }
43  
44  
45 240 ▶sub positive_int {
Subroutine positive_int: called CC=1 SCAR=0.0
Pod documented
46 240 my $i = shift;
47 240 m_to_n($i, 1, $i)
48 }
49  
50  
51 10 __PACKAGE__
« Karel/Robot.pm ↑ Summary Karel/Parser.pm »