blib/lib/Language/Farnsworth/Value.pm

filter: Statementstmt 84.2% 48 / 57 Branchbran 72.2% 13 / 18 Conditioncond 52.9% 9 / 17 MC/DCmcdc 27.2% 3 / 11 Subroutinesub 61.1% 11 / 18 Podpod 0.0% 0 / 13 totaltotal 62.6% 84 / 134 CC 17 SCAR 20.0
CC
17
Cov
76%
ismediumtype
16.9
sethomescope
6.0
conforms
4.0
CRAP 7.4
« blib/lib/Language/Farnsworth/Variables.pm ↑ Summary Farnsworth.yp »
1 #new value class!
2 package Language::Farnsworth::Value;
3  
4 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 4 ▶use Language::Farnsworth::Error;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 4 ▶use Scalar::Util qw/weaken/;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 sub setref
13 568 ▶{
Subroutine setref: called CC=1 SCAR=0.0
Pod undocumented
14 568 my $self = shift;
15 568 my $ref = shift;
16 568 $self->{_ref} = $ref;
17 }
18  
19 sub sethomescope
20 0 ▶{
Subroutine sethomescope: not called CC=2 SCAR=17.9
Pod undocumented
21 0 my $self = shift;
22 0 my $scope = shift; #Farnsworth::Variables type
23
24 0 ▶ unless ($self->{_homescope})
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"_homescope"}) 0 0 0
25 {
26 0 $self->{_homescope} = $scope;
27 0 weaken $self->{_homescope};
28 }
29 }
30  
31 sub gethomescope
32 0 ▶{
Subroutine gethomescope: not called CC=1 SCAR=6.9
Pod undocumented
33 0 return $_[0]->{_homescope};
34 }
35  
36 sub getref
37 178 ▶{
Subroutine getref: called CC=1 SCAR=0.0
Pod undocumented
38 178 my $self = shift;
39 178 return $self->{_ref};
40 }
41  
42 sub istype
43 235 ▶{
Subroutine istype: called CC=1 SCAR=0.0
Pod undocumented
44 235 my $self = shift;
45 235 my $allow = shift; #type to allow!
46  
47 235 return ref($self) =~ /\Q$allow/i;
48 }
49  
50 sub type
51 0 ▶{
Subroutine type: not called CC=1 SCAR=6.9
Pod undocumented
52 0 return "Value (BUG)";
53 }
54  
55 sub ismediumtype
56 132 ▶{
Subroutine ismediumtype: called CC=12 SCAR=28.3
Pod undocumented
57 132 my $self = shift;
58 132 my $allow = shift; #type to allow!
59 132 ▶ $allow ||= "";
Condition50%1/2
$allow ||= ""
l!l
0132
MC/DC0%0/1
$allow ||= ""
$allow
Truth table50%1/2
A
A= $allow
Aresult
11
00
60
61 132 ▶ if ($self->isa("Language::Farnsworth::Value::Array") && $allow ne "Array")
Branch: 5 branches
BranchTrueFalseTotal
if ($self->isa('Language::Farnsworth::Value::Array') and $allow ne 'Array') { } 126 6 132
elsif ($self->isa('Language::Farnsworth::Value::Boolean') and $allow ne 'Boolean') { } 0 6 6
elsif ($self->isa('Language::Farnsworth::Value::String') and $allow ne 'String') { } 1 5 6
elsif ($self->isa('Language::Farnsworth::Value::Date') and $allow ne 'Date') { } 1 4 5
elsif ($self->isa('Language::Farnsworth::Value::Undef') and $allow ne 'Undef') { } 0 8 8
Condition66%2/3
$self->isa("Language::Farnsworth::Value::Array") and $allow ne "Array"
!ll&&!rl&&r
60126
MC/DC50%1/2
$self->isa("Language::Farnsworth::Value::Array") and $allow ne "Array"
$self->isa("Language::Farnsworth::Value::Array") $allow ne "Array"
Truth table66%2/3
A and B
A= $self->isa("Language::Farnsworth::Value::Array")B= $allow ne "Array"
ABresult
0X0
100
111
62 {
63 126 return 1;
64 }
65 ▶ elsif ($self->isa("Language::Farnsworth::Value::Boolean") && $allow ne "Boolean")
Condition33%1/3
$self->isa("Language::Farnsworth::Value::Boolean") and $allow ne "Boolean"
!ll&&!rl&&r
600
MC/DC0%0/2
$self->isa("Language::Farnsworth::Value::Boolean") and $allow ne "Boolean"
$self->isa("Language::Farnsworth::Value::Boolean") $allow ne "Boolean"
Truth table33%1/3
A and B
A= $self->isa("Language::Farnsworth::Value::Boolean")B= $allow ne "Boolean"
ABresult
0X0
100
111
66 {
67 0 return 1;
68 }
69 ▶ elsif ($self->isa("Language::Farnsworth::Value::String") && $allow ne "String")
Condition66%2/3
$self->isa("Language::Farnsworth::Value::String") and $allow ne "String"
!ll&&!rl&&r
501
MC/DC50%1/2
$self->isa("Language::Farnsworth::Value::String") and $allow ne "String"
$self->isa("Language::Farnsworth::Value::String") $allow ne "String"
Truth table66%2/3
A and B
A= $self->isa("Language::Farnsworth::Value::String")B= $allow ne "String"
ABresult
0X0
100
111
70 {
71 1 return 1;
72 }
73 ▶ elsif ($self->isa("Language::Farnsworth::Value::Date") && $allow ne "Date")
Condition66%2/3
$self->isa("Language::Farnsworth::Value::Date") and $allow ne "Date"
!ll&&!rl&&r
401
MC/DC50%1/2
$self->isa("Language::Farnsworth::Value::Date") and $allow ne "Date"
$self->isa("Language::Farnsworth::Value::Date") $allow ne "Date"
Truth table66%2/3
A and B
A= $self->isa("Language::Farnsworth::Value::Date")B= $allow ne "Date"
ABresult
0X0
100
111
74 {
75 1 return 1;
76 }
77 # promoting Lambda to a High type, so that it can capture the multiplication with other types
78 # elsif ($self->isa("Language::Farnsworth::Value::Lambda") && $allow ne "Lambda")
79 # {
80 # return 1;
81 # }
82 ▶ elsif ($self->isa("Language::Farnsworth::Value::Undef") && $allow ne "Undef")
Condition33%1/3
$self->isa("Language::Farnsworth::Value::Undef") and $allow ne "Undef"
!ll&&!rl&&r
400
MC/DC0%0/2
$self->isa("Language::Farnsworth::Value::Undef") and $allow ne "Undef"
$self->isa("Language::Farnsworth::Value::Undef") $allow ne "Undef"
Truth table33%1/3
A and B
A= $self->isa("Language::Farnsworth::Value::Undef")B= $allow ne "Undef"
ABresult
0X0
100
111
83 {
84 0 return 1;
85 }
86
87 4 return 0;
88 }
89  
90 sub conforms
91 1213 ▶{
Subroutine conforms: called CC=4 SCAR=13.9
Pod undocumented
92 1213 my $self = shift;
93 1213 my $comparator = shift;
94  
95 1213 ▶ if (ref($self) ne ref($comparator))
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self ne ref $comparator) { } 2 1211 1213
96 {
97 2 return 0;
98 }
99 else
100 {
101 1211 ▶ if (ref($self) eq "Language::Farnsworth::Value::Pari")
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self eq 'Language::Farnsworth::Value::Pari') { } 1171 40 1211
102 {
103 1171 my $ret = $self->getdimen()->compare($comparator->getdimen());
104 1171 ▶ return 1 if ($comparator->isvalueone()); #read the sentinal value
Branch: 1 branch
BranchTrueFalseTotal
if $comparator->isvalueone 0 1171 1171
105 1171 return $ret;
106 }
107 else
108 {
109 40 return 1; #for now?
110 }
111 }
112 }
113  
114 sub clone
115 59 ▶{
Subroutine clone: called CC=2 SCAR=6.9
Pod undocumented
116 59 my $self = shift;
117 59 my $class = ref($self);
118  
119 59 my $newself = {};
120 59 $newself->{$_} = $self->{$_} for (keys %$self);
121  
122 59 bless $newself, $class;
123  
124 59 $newself->setref(undef);
125 59 $newself;
126 }
127  
128 sub getpari
129 0 ▶{
Subroutine getpari: not called CC=1 SCAR=0.0
Pod undocumented
130 #error("Attempting to use ");
131 }
132  
133 sub getarray
134 0 ▶{
Subroutine getarray: not called CC=1 SCAR=0.0
Pod undocumented
135 }
136  
137 sub getarrayref
138 0 ▶{
Subroutine getarrayref: not called CC=1 SCAR=0.0
Pod undocumented
139 }
140  
141 sub getstring
142 0 ▶{
Subroutine getstring: not called CC=1 SCAR=0.0
Pod undocumented
143 }
144  
145 4 1;
« blib/lib/Language/Farnsworth/Variables.pm ↑ Summary Farnsworth.yp »