lib/Lingy/Util.pm

filter: Statementstmt 75.0% 39 / 52 Branchbran 81.8% 18 / 22 Conditioncond 66.6% 6 / 9 MC/DCmcdc 60.0% 3 / 5 Subroutinesub 80.0% 8 / 10 Podpod 0.0% 0 / 6 totaltotal 71.1% 74 / 104 CC 15 SCAR 21.2
CC
15
Cov
76%
equiv
13.0
eval_perl
6.0
env_data
6.0
CRAP 8.3
« blib/lib/Lingy/Evaluator.pm ↑ Summary lib/Lingy/Main.pm »
1 53 ▶use strict; use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
2 package Lingy::Util;
3  
4 53 ▶use Lingy::Common;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 9 ▶sub identical {
Subroutine identical: called CC=1 SCAR=0.0
Pod undocumented
7 9 BOOLEAN->new(refaddr($_[0]) == refaddr($_[1]));
8 }
9  
10 #------------------------------------------------------------------------------
11 # Devel functions:
12 #------------------------------------------------------------------------------
13  
14 4 ▶sub applyTo {
Subroutine applyTo: called CC=1 SCAR=0.0
Pod undocumented
15 4 my ($method, $args) = @_;
16 53 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
17 4 &{"$method"}(@$args);
18 }
19  
20 0 ▶sub eval_perl {
Subroutine eval_perl: not called CC=2 SCAR=17.9
Pod undocumented
21 0 my $ret = eval("$_[0]");
22 0 ▶ $_[1] // $ret;
Condition0%0/3
$_[1] // $ret
l!l&&r!l&&!r
000
MC/DC0%0/2
$_[1] // $ret
$_[1] $ret
Truth table0%0/3
A // B
A= $_[1]B= $ret
ABresult
1X1
011
000
23 }
24  
25 2 ▶sub rt_internal { my $m = "$_[0]"; RT->$m }
Subroutine rt_internal: called CC=1 SCAR=0.0
Pod undocumented
26  
27 0 ▶sub env_data {
Subroutine env_data: not called CC=2 SCAR=17.9
Pod undocumented
28 0 my $env = $Lingy::Evaluator::ENV;
29 0 my $www = {};
30 0 my $w = $www;
31 0 my $e = $env;
32 0 ▶ while ($e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($e) 0 0 0
33 0 $w->{'+'} = join ' ', sort CORE::keys %{$e->space};
34 0 $w->{'^'} = {};
35 0 $w = $w->{'^'};
36 0 $e = $e->{outer};
37 }
38 0 bless $www, 'lingy-internal';
39 }
40  
41 20318 ▶sub equiv {
Subroutine equiv: called CC=13 SCAR=25.7
Pod undocumented
42 20318 my ($x, $y) = @_;
43 20318 ▶ return false
Branch: 1 branch
BranchTrueFalseTotal
unless $x->isa("Lingy::ListClass") and $y->isa("Lingy::ListClass") or ref $x eq ref $y 18 20300 20318
Condition100%6/6
$x->isa("Lingy::ListClass") and $y->isa("Lingy::ListClass") or ref $x eq ref $y
l!l&&r!l&&!r
262027418
$x->isa("Lingy::ListClass") and $y->isa("Lingy::ListClass")
!ll&&!rl&&r
20286626
MC/DC100%3/3
$x->isa("Lingy::ListClass") and $y->isa("Lingy::ListClass") or ref $x eq ref $y
$x->isa("Lingy::ListClass") $y->isa("Lingy::ListClass") ref $x eq ref $y
Truth table80%4/5
A and B or C
A= $x->isa("Lingy::ListClass")B= $y->isa("Lingy::ListClass")C= ref $x eq ref $y
ABCresult
11X1
0X11
1011
0X00
1000
44 unless
45 (
46 $x->isa(LISTTYPE) and
47 $y->isa(LISTTYPE)
48 ) or ref($x) eq ref($y);
49 20300 ▶ if ($x->isa(LISTTYPE)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($x->isa("Lingy::ListClass")) 26 20274 20300
50 26 ▶ return false unless @$x == @$y;
Branch: 1 branch
BranchTrueFalseTotal
unless @$x == @$y 5 21 26
51 21 ▶ for (my $i = 0; $i < @$x; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @$x) 23 21 44
52 23 my $bool = equiv($x->[$i], $y->[$i]);
53 23 ▶ return false if "$bool" eq '0';
Branch: 1 branch
BranchTrueFalseTotal
if "$bool" eq 0 0 23 23
54 }
55 21 return true;
56 }
57 20274 ▶ if ($x->isa(HASHMAP)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($x->isa("Lingy::HashMap")) 9 20265 20274
58 9 my @xkeys = sort map "$_", keys %$x;
59 9 my @ykeys = sort map "$_", keys %$y;
60 9 ▶ return false unless @xkeys == @ykeys;
Branch: 1 branch
BranchTrueFalseTotal
unless @xkeys == @ykeys 1 8 9
61 8 my @xvals = map $x->{$_}, @xkeys;
62 8 my @yvals = map $y->{$_}, @ykeys;
63 8 ▶ for (my $i = 0; $i < @xkeys; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @xkeys) 10 7 17
64 10 ▶ return false unless "$xkeys[$i]" eq "$ykeys[$i]";
Branch: 1 branch
BranchTrueFalseTotal
unless "$xkeys[$i]" eq "$ykeys[$i]" 0 10 10
65 10 my $bool = equiv($xvals[$i], $yvals[$i]);
66 10 ▶ return false if "$bool" eq '0';
Branch: 1 branch
BranchTrueFalseTotal
if "$bool" eq 0 1 9 10
67 }
68 7 return true;
69 }
70 20265 BOOLEAN->new($$x eq $$y);
71 }
72  
73 53 1;
« blib/lib/Lingy/Evaluator.pm ↑ Summary lib/Lingy/Main.pm »