| 1 | package Tie::Indexer; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use B::Deparse; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | my $dp = new B::Deparse("-sCi0"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | our $VERSION="0.1"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | no strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | no warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 0 | ▶ | use constant Equals => do { package main; sub { $_[0] eq $_[1] } }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.1
Subroutine
__ANON__: not called CC=1 SCAR=0.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 0 | ▶ | use constant Not => do { package main; sub { !exists $_[1]->{$_[0]}; } }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.1
Subroutine
__ANON__: not called CC=1 SCAR=0.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 0 | ▶ | use constant Exists => do { package main; sub { exists $_[0]->{$_[1]}; } }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.1
Subroutine
__ANON__: not called CC=1 SCAR=0.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 0 | ▶ | use constant IndexSimple => do { package main; sub { Tie::Indexer::get_value(@_); } }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.1
Subroutine
__ANON__: not called CC=1 SCAR=0.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 0 | ▶ | use constant IndexExists => do{ package main; sub { keys %{Tie::Indexer::get_value(@_)}; } }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.4
Subroutine
BEGIN: not called CC=1 SCAR=0.4
Subroutine
__ANON__: not called CC=1 SCAR=0.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | my %operators = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | '=' => Equals, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | '!' => Not, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 'E' => Exists, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 1 | my %codeindex; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 2 | ▶ | sub code2text { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
code2text: called CC=3 SCAR=11.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 2 | my ($operator) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 2 | ▶ | return undef if !defined $operator; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 2 | ▶ | if (!exists $codeindex{$operator}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 2 | $codeindex{$operator} = $dp->coderef2text($operator); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 2 | $codeindex{$operator} =~ s/\n/ /g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 2 | return $codeindex{$operator}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 1 | my %indexers = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | code2text(Equals) => IndexSimple, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | code2text(Exists) => IndexExists, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | sub get_value { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_value: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | my ($tie, $expr, $node) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | return $node if !defined $expr || $expr eq ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $expr or $expr eq ""
MC/DC0%0/2
not defined $expr or $expr eq ""
not defined $expr
$expr eq ""
Truth table0%0/3
not(A) or B
A= not defined $exprB= $expr eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | my ($prefix) = ($expr =~ m/^([a-z]+);/); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | $expr =~ s/^[a-z]+;//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | my @path = split("/",$expr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | my $value = $node; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | while (@path) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | if (UNIVERSAL::isa($value,'HASH')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | $value = $value->{shift @path}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | } elsif (UNIVERSAL::isa($value,'ARRAY')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | $value = $value->[shift @path]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | undef $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | undef @path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | return $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 3 | ▶ | sub deindex_node { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
deindex_node: called CC=5 SCAR=26.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 3 | my ($tie, $node, $nodeid) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 3 | foreach my $index (get_indices($tie)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | if ($$index[3]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | delete $$index[0]{$_}{$nodeid} foreach ($$index[3]->($tie,$$index[2],$node,$$index[0])); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | delete $$index[0]{$_}{$nodeid} foreach ($$index[4]->($tie,$$index[2],$node,$$index[0])); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | sub index_node_single { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
index_node_single: not called CC=5 SCAR=27.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | my ($tie, $node, $nodeid, $index) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | if ($$index[3]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 1 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | $$index[0]{$_}{$nodeid} = undef foreach ($$index[3]->($tie,$$index[2],$node,$$index[0])); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | foreach my $value ($$index[4]->($tie,$$index[2],$node,$$index[0])) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | $$index[0]{$value}{$nodeid} = undef if ($$index[1]->($value,get_value($tie,$$index[2],$node))); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 3 | ▶ | sub index_node { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
index_node: called CC=2 SCAR=7.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 3 | my ($tie, $node, $nodeid) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 3 | foreach my $index (get_indices($tie)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | index_node_single(@_,$index); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 6 | ▶ | sub get_indices { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_indices: called CC=8 SCAR=33.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 6 | my ($tie) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 6 | my @res; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 6 | ▶ | my $index = $tie->_get_index() || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$tie->_get_index || {}
MC/DC0%0/1
$tie->_get_index || {}
$tie->_get_index
Truth table50%1/2
A
A= $tie->_get_index
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 6 | ▶ | while (my ($expr, $eindex) = each %$index) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | ▶ | next if $expr =~ m/^\x{200b}[^\x{200b}]/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | $expr =~ s/^\x{200b}\x{200b}/\x{200b}/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | my $values = eval "no strict; package main; return sub ".$$eindex{"\x{200b}values"} if exists $$eindex{"\x{200b}values"}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | $values ||= do { no strict; package main; sub { keys %{$_[3]} } }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=2.9
Subroutine
__ANON__: not called CC=1 SCAR=2.9
Condition0%0/3
$values ||= do {
package main;
no strict;
sub {
keys %{$_[3];};
}
}
MC/DC0%0/2
$values ||= do {
package main;
no strict;
sub {
keys %{$_[3];};
}
}
$values
do {
package main;
no strict;
sub {
keys %{$_[3];};
}
}
Truth table0%0/3
A ||= B
A= $valuesB= do {
package main;
no strict;
sub {
keys %{$_[3];};
}
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | while (my ($operator, $oindex) = each %$eindex) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | my $indexer = eval "no strict; package main; return sub ".$$index{"\x{200b}indexers"}{$operator} if exists $$index{"\x{200b}indexers"}{$operator}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | push @res, [$oindex, eval "no strict; package main; return sub ".$operator, $expr, $indexer, $values]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 6 | return @res; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | sub get_index { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_index: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | my ($tie, $expr, $operator, $force) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | $operator = code2text($operator); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | my $index = $tie->_get_index() || return undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$tie->_get_index || (return undef)
MC/DC0%0/1
$tie->_get_index || (return undef)
$tie->_get_index
Truth table0%0/2
A
A= $tie->_get_index
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | $expr = '' if (!defined $expr); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | $expr =~ s/^\x{200b}/\x{200b}\x{200b}/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | return undef if (!$force && (!exists $$index{$expr} || !exists $$index{$expr}{$operator})); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$force or exists $index->{$expr} and exists $index->{$expr}{$operator}
exists $index->{$expr} and exists $index->{$expr}{$operator}
MC/DC0%0/3
$force or exists $index->{$expr} and exists $index->{$expr}{$operator}
$force
exists $index->{$expr}
exists $index->{$expr}{$operator}
Truth table0%0/4
A or B and C
A= $forceB= exists $index->{$expr}C= exists $index->{$expr}{$operator}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | return $$index{$expr}{$operator}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | ▶ | sub add_index { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_index: not called CC=10 SCAR=47.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | my ($tie, $operator, $expr, $indexer, $values) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | ▶ | $operator = $operators{$operator} if (exists $operators{$operator}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | $operator = code2text($operator); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | ▶ | $indexer ||= $indexers{$operator} if (exists $indexers{$operator}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$indexer ||= $indexers{$operator}
MC/DC0%0/2
$indexer ||= $indexers{$operator}
$indexer
$indexers{$operator}
Truth table0%0/3
A ||= B
A= $indexerB= $indexers{$operator}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | $indexer = code2text($indexer); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | $values = code2text($values); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | my $index = $tie->_get_index(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | $$index{"\x{200b}indexers"}{$operator} ||= $indexer if (defined $indexer); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$index->{"\x{200b}indexers"}{$operator} ||= $indexer
MC/DC0%0/2
$index->{"\x{200b}indexers"}{$operator} ||= $indexer
$index->{"\x{200b}indexers"}{$operator}
$indexer
Truth table0%0/3
A ||= B
A= $index->{"\x{200b}indexers"}{$operator}B= $indexer
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | $expr =~ s/^\x{200b}/\x{200b}\x{200b}/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | $$index{$expr} ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$index->{$expr} ||= {}
MC/DC0%0/1
$index->{$expr} ||= {}
$index->{$expr}
Truth table0%0/2
A
A= $index->{$expr}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | $index = $$index{$expr}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | ▶ | $$index{"\x{200b}values"} ||= $values if (defined $values); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$index->{"\x{200b}values"} ||= $values
MC/DC0%0/2
$index->{"\x{200b}values"} ||= $values
$index->{"\x{200b}values"}
$values
Truth table0%0/3
A ||= B
A= $index->{"\x{200b}values"}B= $values
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | ▶ | $$index{$operator} ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$index->{$operator} ||= {}
MC/DC0%0/1
$index->{$operator} ||= {}
$index->{$operator}
Truth table0%0/2
A
A= $index->{$operator}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | sub search { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
search: not called CC=38 SCAR=73.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | my $tie = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | my $base = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | my ($expr, $operator, $value) = ($base, Equals, undef); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | if (ref($base) eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | return (wantarray?values(%$base):(values %$base)[0]) if !@_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | $expr = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | undef $base; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | $expr = $operators{$expr} if (exists $operators{$expr}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | if (!ref($expr) || ref($expr) ne 'CODE') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
not ref $expr or ref $expr ne "CODE"
MC/DC0%0/2
not ref $expr or ref $expr ne "CODE"
not ref $expr
ref $expr ne "CODE"
Truth table0%0/3
not(A) or B
A= not ref $exprB= ref $expr ne "CODE"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | $value = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | ▶ | if (ref($value) eq 'CODE') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | $operator = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | $value = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | } elsif (exists $operators{$value}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | $operator = $operators{$value}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | $value = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | } elsif (ref($expr) eq 'CODE') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | $operator = $expr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | $expr = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | $value = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | my $index; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | if ($operator ne Not) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | if (defined ($index = get_index($tie, $expr, $operator))) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | # do nothing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | ▶ | } elsif (!$base && defined ($index = get_index($tie, $expr, Equals))) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
not $base and defined($index = get_index($tie, $expr, sub { no warnings; $_[0] eq $_[1];}))
MC/DC0%0/2
not $base and defined($index = get_index($tie, $expr, sub { no warnings; $_[0] eq $_[1];}))
not $base
defined($index = get_index($tie, $expr, sub { no warnings; $_[0] eq $_[1];}))
Truth table0%0/3
not(A) and B
A= not $baseB= defined($index = get_index($tie, $expr, sub { no warnings; $_[0] eq $_[1];}))
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | # TODO: use an Equals index for base matches as well? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | # perhaps some heuristic: if (keys %$base > keys %$index) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | my %res; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | foreach my $exp (keys %$index) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | local $_ = $exp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | ▶ | if ($operator->($exp,$value)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | ▶ | $res{$_} ||= $tie->FETCH($_) foreach (keys %{$$index{$exp}}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$res{$_} ||= $tie->FETCH($_)
MC/DC0%0/2
$res{$_} ||= $tie->FETCH($_)
$res{$_}
$tie->FETCH($_)
Truth table0%0/3
A ||= B
A= $res{$_}B= $tie->FETCH($_)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | ▶ | last if !wantarray; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | return search($tie,\%res,@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | ▶ | if (!$index && !$base && (wantarray || $operator eq Not)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
not $index || $base and wantarray || $operator eq sub { no warnings; not exists $_[1]{$_[0]};}
$index || $base
wantarray or $operator eq sub { no warnings; not exists $_[1]{$_[0]};}
MC/DC0%0/4
not $index || $base and wantarray || $operator eq sub { no warnings; not exists $_[1]{$_[0]};}
$index
$base
wantarray
$operator eq sub { no warnings; not exists $_[1]{$_[0]};}
Truth table0%0/5
not(A || B) and C or D
A= $indexB= $baseC= wantarrayD= $operator eq sub { no warnings; not exists $_[1]{$_[0]};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | $base = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | my $key = $tie->FIRSTKEY; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | while (defined $key) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | $$base{$key} = $tie->FETCH($key); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | $key = $tie->NEXTKEY; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | if ($operator eq Not) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | ▶ | if (!$expr) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | return search($tie,$base,@_,{ %$base },Not); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | delete $$expr{$_} foreach (keys %$base); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | return search($tie,$expr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | ▶ | if ($index) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | ▶ | if (defined ($index = $$index{$value})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | ▶ | if (!$base) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | $base = { map { ($_ => $tie->FETCH($_)) } keys %$index }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | foreach my $key (keys %$base) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | delete $$base{$key} if !exists $$index{$key}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | return search($tie,$base,@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | return (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | if (!$base) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | my $key = $tie->FIRSTKEY; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | ▶ | while (defined $key) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | my $node = $tie->FETCH($key); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | local $_ = get_value($tie,$expr,$node); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | return $node if $operator->($_,$value) && search($tie,{$key => $node},@_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
&$operator($_, $value) and search($tie, {$key, $node}, @_)
MC/DC0%0/2
&$operator($_, $value) and search($tie, {$key, $node}, @_)
&$operator($_, $value)
search($tie, {$key, $node}, @_)
Truth table0%0/3
A and B
A= &$operator($_, $value)B= search($tie, {$key, $node}, @_)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | $key = $tie->NEXTKEY; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | ▶ | while (my ($key, $node) = each %$base) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | local $_ = get_value($tie,$expr,$node); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | ▶ | delete $$base{$key} if !$operator->($_,$value); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | return search($tie,$base,@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | ▶ | sub build_index { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_index: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | my ($tie) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | foreach my $index (get_indices($tie)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | foreach my $key (keys %{$$index[0]}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | undef $$index[0]{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | my $key = $tie->FIRSTKEY; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | ▶ | while (defined $key) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | index_node_single($tie,$tie->FETCH($key),$key,$index); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | $key = $tie->NEXTKEY; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 1 | ▶ | no warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 1 | "Dahut!"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||