CLI/Base.pm

filter: Statementstmt 56.6% 34 / 60 Branchbran 50.0% 8 / 16 Conditioncond 33.3% 7 / 21 MC/DCmcdc 0.0% 0 / 10 Subroutinesub 69.2% 9 / 13 Podpod 0.0% 0 / 8 totaltotal 45.3% 58 / 128 CC 16 SCAR 17.0
CC
16
Cov
51%
max
8.8
min
8.0
new
6.0
CRAP 5.4
« CLI/Var.pm ↑ Summary interactive.pl »
1 package CLI::Base;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use CLI qw(INTEGER FLOAT STRING SSTRING TIME DEGREE
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 BOOLEAN typeStr);
8 1 ▶use Astro::Time qw(str2turn);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
Pod undocumented
11 0 my $proto = shift;
12 0 ▶ my $class = ref($proto) || $proto;
Condition0%0/3
ref $proto || $proto
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table0%0/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
13  
14 0 my $name = shift;
15 0 my $value = shift;
16 0 my $type = shift;
17  
18 0 my $self = {
19 NAME => $name,
20 TYPE => $type,
21 VALUE => $value,
22 FUNC => undef,
23 MIN => undef,
24 MAX => undef
25 };
26 0 bless ($self, $class);
27  
28 0 return $self;
29 }
30  
31 0 ▶sub value {
Subroutine value: not called CC=2 SCAR=17.9
Pod undocumented
32 0 my $self = shift;
33 0 ▶ if (@_) {$self->{VALUE} = shift }
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
34 0 return $self->{VALUE};
35 }
36  
37 14 ▶sub type {
Subroutine type: called CC=2 SCAR=7.6
Pod undocumented
38 14 my $self = shift;
39 0 ▶ if (@_) { $self->{TYPE} = shift }
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 14 14
40 14 return $self->{TYPE};
41 }
42  
43 0 ▶sub name {
Subroutine name: not called CC=2 SCAR=17.9
Pod undocumented
44 0 my $self = shift;
45 0 ▶ if (@_) { $self->{NAME} = shift }
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
46 0 return $self->{NAME};
47 }
48  
49 13 ▶sub function {
Subroutine function: called CC=2 SCAR=7.6
Pod undocumented
50 13 my $self = shift;
51 0 ▶ if (@_) { $self->{FUNC} = shift }
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 13 13
52 13 return $self->{FUNC};
53 }
54  
55 11 ▶sub min {
Subroutine min: called CC=6 SCAR=20.8
Pod undocumented
56 11 my $self = shift;
57 11 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 2 9 11
58 2 my $type = $self->type();
59 2 ▶ if (!($type == INTEGER || $type == FLOAT ||
Branch: 1 branch
BranchTrueFalseTotal
unless ($type == 1 or $type == 2 or $type == 5 or $type == 6) 0 2 2
Condition44%4/9
$type == 1 or $type == 2 or $type == 5 or $type == 6
l!l&&r!l&&!r
200
$type == 1 or $type == 2 or $type == 5
l!l&&r!l&&!r
200
$type == 1 or $type == 2
l!l&&r!l&&!r
110
MC/DC0%0/4
$type == 1 or $type == 2 or $type == 5 or $type == 6
$type == 1 $type == 2 $type == 5 $type == 6
Truth table40%2/5
A or B or C or D
A= $type == 1B= $type == 2C= $type == 5D= $type == 6
ABCDresult
1XXX1
01XX1
001X1
00011
00000
60 $type == TIME || $type == DEGREE)) {
61 0 carp 'Cannot set minimum value for type ', typeStr($self->type()), "\n";
62 0 return undef;
63 }
64 2 $self->{MIN} = shift;
65 }
66 11 return $self->{MIN};
67 }
68  
69 10 ▶sub max {
Subroutine max: called CC=6 SCAR=21.8
Pod undocumented
70 10 my $self = shift;
71 10 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 1 9 10
72 1 my $type = $self->type();
73 1 ▶ if (!($type == INTEGER || $type == FLOAT ||
Branch: 1 branch
BranchTrueFalseTotal
unless ($type == 1 or $type == 2 or $type == 5 or $type == 6) 0 1 1
Condition33%3/9
$type == 1 or $type == 2 or $type == 5 or $type == 6
l!l&&r!l&&!r
100
$type == 1 or $type == 2 or $type == 5
l!l&&r!l&&!r
100
$type == 1 or $type == 2
l!l&&r!l&&!r
100
MC/DC0%0/4
$type == 1 or $type == 2 or $type == 5 or $type == 6
$type == 1 $type == 2 $type == 5 $type == 6
Truth table20%1/5
A or B or C or D
A= $type == 1B= $type == 2C= $type == 5D= $type == 6
ABCDresult
1XXX1
01XX1
001X1
00011
00000
74 $type == TIME || $type == DEGREE)) {
75 0 carp 'Cannot set maximum value for type ', $self->type(), "\n";
76 0 return undef;
77 }
78 1 $self->{MAX} = shift;
79 }
80 10 return $self->{MAX};
81 }
82  
83 0 ▶sub parse {
Subroutine parse: not called CC=1 SCAR=6.9
Pod undocumented
84 0 my $self = shift;
85 0 my $string = shift;
86  
87 0 my $name = $self->{NAME};
88  
89 0 carp "Could not parse \"$name $string\"";
90  
91 }
92  
93 1 1;
94  
« CLI/Var.pm ↑ Summary interactive.pl »