« blib/lib/Language/Farnsworth/Value/Undef.pm
↑ Summary
blib/lib/Language/Farnsworth/Value/Date.pm »
| 1 | package Language::Farnsworth::Value::String; | ||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||
| 3 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use Language::Farnsworth::Dimension; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 7 | 4 | ▶ | use base 'Language::Farnsworth::Value'; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 8 | 4 | ▶ | use Language::Farnsworth::Error; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||
| 10 | 4 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||
| 12 | 4 | our $VERSION = 0.6; | |||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||
| 14 | use overload | ||||||||||||||||||||||||||||||||||||
| 15 | 4 | ▶ | '+' => \&add, | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 16 | '-' => \&subtract, | ||||||||||||||||||||||||||||||||||||
| 17 | '*' => \&mult, | ||||||||||||||||||||||||||||||||||||
| 18 | '/' => \&div, | ||||||||||||||||||||||||||||||||||||
| 19 | '%' => \&mod, | ||||||||||||||||||||||||||||||||||||
| 20 | '**' => \&pow, | ||||||||||||||||||||||||||||||||||||
| 21 | '<=>' => \&compare, | ||||||||||||||||||||||||||||||||||||
| 22 | 4 | 'bool' => \&bool; | |||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||
| 24 | 4 | ▶ | use base qw(Language::Farnsworth::Value); | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||
| 26 | #this is the REQUIRED fields for Language::Farnsworth::Value subclasses | ||||||||||||||||||||||||||||||||||||
| 27 | # | ||||||||||||||||||||||||||||||||||||
| 28 | #dimen => a Language::Farnsworth::Dimension object | ||||||||||||||||||||||||||||||||||||
| 29 | # | ||||||||||||||||||||||||||||||||||||
| 30 | #this is so i can make a -> conforms in Language::Farnsworth::Value, to replace the existing code, i'm also planning on adding some definitions such as, TYPE_PARI, TYPE_STRING, TYPE_LAMBDA, TYPE_DATE, etc. to make certain things easier | ||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||
| 32 | sub new | ||||||||||||||||||||||||||||||||||||
| 33 | 78 | ▶ | { | ||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=4 SCAR=14.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 34 | 78 | my $class = shift; | |||||||||||||||||||||||||||||||||||
| 35 | 78 | my $value = shift; | |||||||||||||||||||||||||||||||||||
| 36 | 78 | my $lang = shift; | |||||||||||||||||||||||||||||||||||
| 37 | 78 | my $outmagic = shift; #i'm still not sure on this one | |||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||
| 39 | 78 | ▶ | error "Non string given as \$value to constructor" unless ref($value) eq "" && defined($value); | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $value eq "" and defined $value
MC/DC0%0/2
ref $value eq "" and defined $value
ref $value eq ""
defined $value
Truth table33%1/3
A and B
A= ref $value eq ""B= defined $value
| |||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||
| 41 | 78 | my $self = {}; | |||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||
| 43 | 78 | bless $self, $class; | |||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||
| 45 | 78 | $self->{outmagic} = $outmagic; | |||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||
| 47 | { | ||||||||||||||||||||||||||||||||||||
| 48 | 4 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 49 | 78 | $self->{string} = "".$value; | |||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||
| 51 | 78 | ▶ | $self->{lang} = $lang || ""; | ||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$lang || ''
MC/DC0%0/1
$lang || ''
$lang
Truth table50%1/2
A
A= $lang
| |||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||
| 53 | 78 | return $self; | |||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||
| 56 | sub getstring | ||||||||||||||||||||||||||||||||||||
| 57 | 63 | ▶ | { | ||||||||||||||||||||||||||||||||||
|
Subroutine
getstring: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 58 | 63 | return $_[0]->{string}; | |||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||
| 61 | sub getlang | ||||||||||||||||||||||||||||||||||||
| 62 | 3 | ▶ | { | ||||||||||||||||||||||||||||||||||
|
Subroutine
getlang: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 63 | 3 | return $_[0]->{lang}; | |||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||
| 66 | sub type | ||||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||
|
Subroutine
type: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 68 | 0 | return "String"; | |||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||
| 71 | ####### | ||||||||||||||||||||||||||||||||||||
| 72 | #The rest of this code can be GREATLY cleaned up by assuming that $one is of type, Language::Farnsworth::Value::Pari, this means that i can slowly redo a lot of this code | ||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||
| 74 | sub add | ||||||||||||||||||||||||||||||||||||
| 75 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||
|
Subroutine
add: called CC=8 SCAR=22.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 76 | 1 | my ($one, $two, $rev) = @_; | |||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||
| 78 | 1 | ▶ | error "Non reference given to addition of string" unless (ref($two)); | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||
| 80 | #if we're not being added to a Language::Farnsworth::Value::Pari, the higher class object needs to handle it. | ||||||||||||||||||||||||||||||||||||
| 81 | 1 | ▶ | error "Scalar value given to addition of string" if ($two->isa("Language::Farnsworth::Value::Pari")); | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 82 | 1 | ▶ | return $two->add($one, !$rev) unless ($two->ismediumtype()); | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||
| 84 | 1 | ▶ | if (!$two->istype("String")) | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 85 | { | ||||||||||||||||||||||||||||||||||||
| 86 | 0 | error "Given non string to string operation"; | |||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||
| 90 | #NOTE TO SELF this needs to be more helpful, i'll probably do this by creating an "error" class that'll be captured in ->evalbranch's recursion and use that to add information from the parse tree about WHERE the error occured | ||||||||||||||||||||||||||||||||||||
| 91 | 1 | my $new; | |||||||||||||||||||||||||||||||||||
| 92 | 1 | ▶ | $new = $one->getstring() . $two->getstring() unless $rev; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 93 | 1 | ▶ | $new = $two->getstring() . $one->getstring() if $rev; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||
| 95 | 1 | my $lang = ""; | |||||||||||||||||||||||||||||||||||
| 96 | 1 | ▶ | $lang = $one->getlang() if ($one->getlang() eq $two->getlang()); #if we know their language, and they're the same, just keep it | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||
| 98 | 1 | return new Language::Farnsworth::Value::String($new); #return new string | |||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||
| 101 | sub subtract | ||||||||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||
|
Subroutine
subtract: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 103 | 0 | my ($one, $two, $rev) = @_; | |||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||
| 105 | 0 | ▶ | error "Non reference given to subtraction of string" unless (ref($two)); | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||
| 107 | #if there's a higher type, use it, subtraction otherwise doesn't make sense on arrays | ||||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | error "Scalar value given to subtraction to strings" if ($two->isa("Language::Farnsworth::Value::Pari")); | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | return $two->subtract($one, !$rev) unless ($two->ismediumtype()); | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | if (!$two->istype("String")) | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 111 | { | ||||||||||||||||||||||||||||||||||||
| 112 | 0 | error "Given non string to string operation"; | |||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||
| 115 | 0 | error "Subtracting strings? what did you think this would do, create a black hole?"; | |||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||
| 118 | sub modulus | ||||||||||||||||||||||||||||||||||||
| 119 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||
|
Subroutine
modulus: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 120 | 0 | my ($one, $two, $rev) = @_; | |||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | error "Non reference given to modulus of string" unless (ref($two)); | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||
| 124 | #if there's a higher type, use it, subtraction otherwise doesn't make sense on arrays | ||||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | error "Scalar value given to modulus of string" if ($two->isa("Language::Farnsworth::Value::Pari")); | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | return $two->mod($one, !$rev) unless ($two->ismediumtype()); | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | if (!$two->istype("String")) | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 128 | { | ||||||||||||||||||||||||||||||||||||
| 129 | 0 | error "Given non string to string operation"; | |||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||
| 132 | 0 | error "Modulusing strings? what did you think this would do, create a black hole?"; | |||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||
| 135 | sub mult | ||||||||||||||||||||||||||||||||||||
| 136 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||
|
Subroutine
mult: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 137 | 0 | my ($one, $two, $rev) = @_; | |||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | error "Non reference given to multiplication of string" unless (ref($two)); | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||
| 141 | #if there's a higher type, use it, subtraction otherwise doesn't make sense on arrays | ||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | error "Scalar value given to multiplcation of string" if ($two->isa("Language::Farnsworth::Value::Pari")); | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 143 | 0 | ▶ | return $two->mult($one, !$rev) unless ($two->ismediumtype()); | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | if (!$two->istype("String")) | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 145 | { | ||||||||||||||||||||||||||||||||||||
| 146 | 0 | error "Given non string to string operation"; | |||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||
| 149 | 0 | error "Multiplying strings? what did you think this would do, create a black hole?"; | |||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||
| 152 | sub div | ||||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||
|
Subroutine
div: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 154 | 0 | my ($one, $two, $rev) = @_; | |||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||
| 156 | 0 | ▶ | error "Non reference given to division of string" unless (ref($two)); | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||
| 158 | #if there's a higher type, use it, subtraction otherwise doesn't make sense on arrays | ||||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | error "Scalar value given to division of string" if ($two->isa("Language::Farnsworth::Value::Pari")); | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | return $two->div($one, !$rev) unless ($two->ismediumtype()); | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | if (!$two->istype("String")) | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 162 | { | ||||||||||||||||||||||||||||||||||||
| 163 | 0 | error "Given non string to string operation"; | |||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||
| 166 | 0 | error "Dividing string? what did you think this would do, create a black hole?"; | |||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||
| 169 | sub bool | ||||||||||||||||||||||||||||||||||||
| 170 | 40 | ▶ | { | ||||||||||||||||||||||||||||||||||
|
Subroutine
bool: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 171 | 40 | my $self = shift; | |||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||
| 173 | #seems good enough of an idea to me | ||||||||||||||||||||||||||||||||||||
| 174 | #i have a bug HERE | ||||||||||||||||||||||||||||||||||||
| 175 | #print "BOOLCONV\n"; | ||||||||||||||||||||||||||||||||||||
| 176 | #print Dumper($self); | ||||||||||||||||||||||||||||||||||||
| 177 | #print "ENDBOOLCONV\n"; | ||||||||||||||||||||||||||||||||||||
| 178 | 40 | ▶ | return length($self->getstring())?1:0; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||
| 181 | sub pow | ||||||||||||||||||||||||||||||||||||
| 182 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||
|
Subroutine
pow: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 183 | 0 | my ($one, $two, $rev) = @_; | |||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||
| 185 | 0 | ▶ | error "Non reference given to exponentiation of string" unless (ref($two)); | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||
| 187 | #if there's a higher type, use it, subtraction otherwise doesn't make sense on arrays | ||||||||||||||||||||||||||||||||||||
| 188 | 0 | ▶ | error "Exponentiating strings? what did you think this would do, create a black hole?" if ($two->isa("Language::Farnsworth::Value::Pari")); | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 189 | 0 | ▶ | return $two->pow($one, !$rev) unless ($two->ismediumtype()); | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 190 | 0 | ▶ | if (!$two->istype("String")) | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 191 | { | ||||||||||||||||||||||||||||||||||||
| 192 | 0 | error "Given non string to string operation"; | |||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||
| 195 | 0 | error "Exponentiating strings? what did you think this would do, create a black hole?"; | |||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||
| 198 | sub __compare | ||||||||||||||||||||||||||||||||||||
| 199 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||
|
Subroutine
__compare: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||
| 200 | 0 | my ($a1, $a2) = @_; | |||||||||||||||||||||||||||||||||||
| 201 | 0 | my $same = 0; | |||||||||||||||||||||||||||||||||||
| 202 | 0 | my $ea = each_array(@$a1, @$a2); | |||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | while(my ($first, $second) = $ea->()) | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 205 | { | ||||||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | $same = $first > $second ? 1 : -1 and last if $first != $second | ||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/5
$first != $second && (($same = $first > $second ? 1 : -1) && (last))
$same = $first > $second ? 1 : -1 and last
MC/DC0%0/2
$first != $second && (($same = $first > $second ? 1 : -1) && (last))
$first != $second
$same = $first > $second ? 1 : -1
Truth table0%0/3
A && B
A= $first != $secondB= $same = $first > $second ? 1 : -1
| |||||||||||||||||||||||||||||||||||||
| 207 | } # shortcircuits | ||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||
| 209 | 0 | return $same; | |||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||
| 212 | sub compare | ||||||||||||||||||||||||||||||||||||
| 213 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||
|
Subroutine
compare: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 214 | 0 | my ($one, $two, $rev) = @_; | |||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||
| 216 | 0 | ▶ | error "Non reference given to compare of string" unless (ref($two)); | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||
| 218 | #if we're not being added to a Language::Farnsworth::Value::Pari, the higher class object needs to handle it. | ||||||||||||||||||||||||||||||||||||
| 219 | 0 | ▶ | error "Scalar value given to division to string" if ($two->isa("Language::Farnsworth::Value::Pari")); | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 220 | 0 | ▶ | return $two->compare($one, !$rev) unless ($two->ismediumtype()); | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||
| 222 | 0 | ▶ | my $rv = $rev ? -1 : 1; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 223 | #check for $two being a simple value | ||||||||||||||||||||||||||||||||||||
| 224 | 0 | my $tv = $two->getstring(); | |||||||||||||||||||||||||||||||||||
| 225 | 0 | my $ov = $one->getstring(); | |||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||
| 227 | #i also need to check the units, but that will come later | ||||||||||||||||||||||||||||||||||||
| 228 | #NOTE TO SELF this needs to be more helpful, i'll probably do something by adding stuff in ->new to be able to fetch more about the processing | ||||||||||||||||||||||||||||||||||||
| 229 | 0 | ▶ | error "Unable to process different units in compare\n" unless $one->conforms($two); #always call this on one, since $two COULD be some other object | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||
| 231 | #moving this down so that i don't do any math i don't have to | ||||||||||||||||||||||||||||||||||||
| 232 | 0 | my $new = $ov cmp $tv; | |||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||
| 234 | 0 | return $new * $rv; | |||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||