ModeMerge/Mode/Base.pm

filter: Statementstmt 94.6% 351 / 371 Branchbran 92.4% 183 / 198 Conditioncond 88.4% 122 / 138 MC/DCmcdc 75.3% 58 / 77 Subroutinesub 80.0% 20 / 25 Podpod 70.0% 7 / 10 totaltotal 90.4% 741 / 819 CC 159 SCAR 34.0
CC
159
Cov
93%
merge_HASH_HASH
51.0
_merge_gen
35.1
_gen_left
27.7
CRAP 30.1
↑ Summary ModeMerge.pm »
1 package Data::ModeMerge::Mode::Base;
2  
3 38 our $DATE = '2021-08-15'; # DATE
4 38 our $VERSION = '0.360'; # VERSION
5  
6 38 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 38 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 38 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 #use Data::Dmp;
11  
12 #use Log::Any '$log';
13 38 ▶use Mo qw(build default);
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 #use Data::Clone qw/clone/;
16  
17 38 has merger => (is => 'rw');
18 38 has prefix => (is => 'rw');
19 38 has prefix_re => (is => 'rw');
20 38 has check_prefix_sub => (is => 'rw');
21 38 has add_prefix_sub => (is => 'rw');
22 38 has remove_prefix_sub => (is => 'rw');
23  
24 0 ▶sub name {
Subroutine name: not called CC=1 SCAR=6.9
Pod documented
25 0 die "Subclass must provide name()";
26 }
27  
28 0 ▶sub precedence_level {
Subroutine precedence_level: not called CC=1 SCAR=6.9
Pod documented
29 0 die "Subclass must provide precedence_level()";
30 }
31  
32 0 ▶sub default_prefix {
Subroutine default_prefix: not called CC=1 SCAR=6.9
Pod documented
33 0 die "Subclass must provide default_prefix()";
34 }
35  
36 0 ▶sub default_prefix_re {
Subroutine default_prefix_re: not called CC=1 SCAR=6.9
Pod documented
37 0 die "Subclass must provide default_prefix_re()";
38 }
39  
40 1980 ▶sub BUILD {
Subroutine BUILD: called CC=1 SCAR=0.0
Pod undocumented
41 1980 my ($self) = @_;
42 1980 $self->prefix($self->default_prefix);
43 1980 $self->prefix_re($self->default_prefix_re);
44 }
45  
46 11476 ▶sub check_prefix {
Subroutine check_prefix: called CC=2 SCAR=7.6
Pod documented
47 11476 my ($self, $hash_key) = @_;
48 11476 ▶ if ($self->check_prefix_sub) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->check_prefix_sub) { } 0 11476 11476
49 0 $self->check_prefix_sub->($hash_key);
50 } else {
51 11476 $hash_key =~ $self->prefix_re;
52 }
53 }
54  
55 101 ▶sub add_prefix {
Subroutine add_prefix: called CC=2 SCAR=6.9
Pod documented
56 101 my ($self, $hash_key) = @_;
57 101 ▶ if ($self->add_prefix_sub) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->add_prefix_sub) { } 4 97 101
58 4 $self->add_prefix_sub->($hash_key);
59 } else {
60 97 $self->prefix . $hash_key;
61 }
62 }
63  
64 942 ▶sub remove_prefix {
Subroutine remove_prefix: called CC=2 SCAR=6.9
Pod documented
65 942 my ($self, $hash_key) = @_;
66 942 ▶ if ($self->remove_prefix_sub) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->remove_prefix_sub) { } 10 932 942
67 10 $self->remove_prefix_sub->($hash_key);
68 } else {
69 932 my $re = $self->prefix_re;
70 932 $hash_key =~ s/$re//;
71 932 $hash_key;
72 }
73 }
74  
75 13 ▶sub merge_ARRAY_ARRAY {
Subroutine merge_ARRAY_ARRAY: called CC=11 SCAR=25.8
Pod undocumented
76 13 my ($self, $key, $l, $r) = @_;
77 13 my $mm = $self->merger;
78 13 my $c = $mm->config;
79 13 ▶ return $self->merge_SCALAR_SCALAR($key, $l, $r) unless $c->recurse_array;
Branch: 1 branch
BranchTrueFalseTotal
unless $c->recurse_array 9 4 13
80 4 ▶ return if $c->wanted_path && !$mm->_path_is_included($mm->path, $c->wanted_path);
Branch: 1 branch
BranchTrueFalseTotal
if $c->wanted_path and not $mm->_path_is_included($mm->path, $c->wanted_path) 0 4 4
Condition33%1/3
$c->wanted_path and not $mm->_path_is_included($mm->path, $c->wanted_path)
!ll&&!rl&&r
400
MC/DC0%0/2
$c->wanted_path and not $mm->_path_is_included($mm->path, $c->wanted_path)
$c->wanted_path not $mm->_path_is_included($mm->path, $c->wanted_path)
Truth table33%1/3
A and not(B)
A= $c->wanted_pathB= not $mm->_path_is_included($mm->path, $c->wanted_path)
ABresult
0X0
100
111
81  
82 4 my @res;
83 my @backup;
84 4 my $la = @$l;
85 4 my $lb = @$r;
86 4 push @{ $mm->path }, -1;
87 4 ▶ for my $i (0..($la > $lb ? $la : $lb)-1) {
Branch: 1 branch
BranchTrueFalseTotal
$la > $lb ? : 1 3 4
88 #print "DEBUG: merge_A_A: #$i: a->[$i]=".Data::Dumper->new([$l->[$i]])->Indent(0)->Terse(1)->Dump.", b->[$i]=".Data::Dumper->new([$r->[$i]])->Indent(0)->Terse(1)->Dump."\n";
89 6 $mm->path->[-1] = $i;
90 6 ▶ if ($i < $la && $i < $lb) {
Branch: 2 branches
BranchTrueFalseTotal
if ($i < $la and $i < $lb) { } 5 1 6
elsif ($i < $la) { } 1 0 1
Condition66%2/3
$i < $la and $i < $lb
!ll&&!rl&&r
015
MC/DC50%1/2
$i < $la and $i < $lb
$i < $la $i < $lb
Truth table66%2/3
A and B
A= $i < $laB= $i < $lb
ABresult
0X0
100
111
91 5 push @backup, $l->[$i];
92 5 my ($subnewkey, $subres, $subbackup, $is_circular) = $mm->_merge($i, $l->[$i], $r->[$i], $c->default_mode);
93 5 ▶ last if @{ $mm->errors };
Branch: 1 branch
BranchTrueFalseTotal
if @{$mm->errors;} 0 5 5
94 5 ▶ if ($is_circular) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_circular) { } 0 5 5
95 0 push @res, undef;
96 #print "DEBUG: pushing todo to mem<".$mm->cur_mem_key.">\n";
97 0 ▶ push @{ $mm->mem->{ $mm->cur_mem_key }{todo} }, sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
98 0 my ($subnewkey, $subres, $subbackup) = @_;
99 #print "DEBUG: Entering todo subroutine (i=$i)\n";
100 0 $res[$i] = $subres;
101 }
102 0 } else {
103 5 push @res, $subres;# if defined($newkey); = we allow DELETE on array?
104 }
105 } elsif ($i < $la) {
106 1 push @res, $l->[$i];
107 } else {
108 0 push @res, $r->[$i];
109 }
110 }
111 4 pop @{ $mm->path };
112 4 ($key, \@res, \@backup);
113 }
114  
115 18 ▶sub _prefilter_hash {
Subroutine _prefilter_hash: called CC=6 SCAR=17.9
116 18 my ($self, $h, $desc, $sub) = @_;
117 18 my $mm = $self->merger;
118  
119 18 ▶ if (ref($sub) ne 'CODE') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $sub ne "CODE") 3 15 18
120 3 $mm->push_error("$desc failed: filter must be a coderef");
121 3 return;
122 }
123  
124 15 my $res = {};
125 15 for (keys %$h) {
126 17 my @r = $sub->($_, $h->{$_});
127 17 ▶ while (my ($k, $v) = splice @r, 0, 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = splice(@r, 0, 2)) 21 16 37
128 21 ▶ next unless defined $k;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $k 4 17 21
129 17 ▶ if (exists $res->{$k}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $res->{$k}) 1 16 17
130 1 $mm->push_error("$desc failed; key conflict: ".
131 "$_ -> $k, but key $k already exists");
132 1 return;
133 }
134 16 $res->{$k} = $v;
135 }
136 }
137  
138 14 $res;
139 }
140  
141 # turn {[prefix]key => val, ...} into { key => [MODE, val], ...}, push
142 # error if there's conflicting key
143 566 ▶sub _gen_left {
Subroutine _gen_left: called CC=27 SCAR=33.2
144 566 my ($self, $l, $mode, $esub, $ep, $ip, $epr, $ipr) = @_;
145 566 my $mm = $self->merger;
146 566 my $c = $mm->config;
147  
148 #print "DEBUG: Entering _gen_left(".dmp($l).", $mode, ...)\n";
149  
150 566 ▶ if ($c->premerge_pair_filter) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c->premerge_pair_filter) 11 555 566
151 11 $l = $self->_prefilter_hash($l, "premerge filter left hash",
152 $c->premerge_pair_filter);
153 11 ▶ return if @{ $mm->errors };
Branch: 1 branch
BranchTrueFalseTotal
if @{$mm->errors;} 4 7 11
154 }
155  
156 562 my $hl = {};
157 562 ▶ if ($c->parse_prefix) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c->parse_prefix) { } 553 9 562
158 553 for (keys %$l) {
159 1171 my $do_parse = 1;
160 1171 ▶ $do_parse = 0 if $do_parse && $ep && $mm->_in($_, $ep);
Branch: 1 branch
BranchTrueFalseTotal
if $do_parse and $ep and $mm->_in($_, $ep) 1 1170 1171
Condition83%5/6
$do_parse and $ep and $mm->_in($_, $ep)
!ll&&!rl&&r
1144261
$do_parse and $ep
!ll&&!rl&&r
0114427
MC/DC66%2/3
$do_parse and $ep and $mm->_in($_, $ep)
$do_parse $ep $mm->_in($_, $ep)
Truth table75%3/4
A and B and C
A= $do_parseB= $epC= $mm->_in($_, $ep)
ABCresult
0XX0
10X0
1100
1111
161 1171 ▶ $do_parse = 0 if $do_parse && $ip && !$mm->_in($_, $ip);
Branch: 1 branch
BranchTrueFalseTotal
if $do_parse and $ip and not $mm->_in($_, $ip) 25 1146 1171
Condition83%5/6
$do_parse and $ip and not $mm->_in($_, $ip)
!ll&&!rl&&r
1146025
$do_parse and $ip
!ll&&!rl&&r
1114525
MC/DC66%2/3
$do_parse and $ip and not $mm->_in($_, $ip)
$do_parse $ip not $mm->_in($_, $ip)
Truth table75%3/4
A and B and not(C)
A= $do_parseB= $ipC= not $mm->_in($_, $ip)
ABCresult
0XX0
10X0
1100
1111
162 1171 ▶ $do_parse = 0 if $do_parse && $epr && /$epr/;
Branch: 1 branch
BranchTrueFalseTotal
if $do_parse and $epr and /$epr/ 2 1169 1171
Condition100%6/6
$do_parse and $epr and /$epr/
!ll&&!rl&&r
1152172
$do_parse and $epr
!ll&&!rl&&r
26112619
MC/DC100%3/3
$do_parse and $epr and /$epr/
$do_parse $epr /$epr/
Truth table100%4/4
A and B and C
A= $do_parseB= $eprC= /$epr/
ABCresult
0XX0
10X0
1100
1111
163 1171 ▶ $do_parse = 0 if $do_parse && $ipr && !/$ipr/;
Branch: 1 branch
BranchTrueFalseTotal
if $do_parse and $ipr and not /$ipr/ 15 1156 1171
Condition100%6/6
$do_parse and $ipr and not /$ipr/
!ll&&!rl&&r
1152415
$do_parse and $ipr
!ll&&!rl&&r
28112419
MC/DC100%3/3
$do_parse and $ipr and not /$ipr/
$do_parse $ipr not /$ipr/
Truth table100%4/4
A and B and not(C)
A= $do_parseB= $iprC= not /$ipr/
ABCresult
0XX0
10X0
1100
1111
164  
165 1171 ▶ if ($do_parse) {
Branch: 1 branch
BranchTrueFalseTotal
if ($do_parse) { } 1128 43 1171
166 1128 my $old = $_;
167 1128 my $m2;
168 1128 ($_, $m2) = $mm->remove_prefix($_);
169 1127 ▶ next if $esub && !$esub->($_);
Branch: 1 branch
BranchTrueFalseTotal
if $esub and not &$esub($_) 589 538 1127
Condition66%2/3
$esub and not &$esub($_)
!ll&&!rl&&r
0538589
MC/DC50%1/2
$esub and not &$esub($_)
$esub not &$esub($_)
Truth table66%2/3
A and not(B)
A= $esubB= not &$esub($_)
ABresult
0X0
100
111
170 538 ▶ if ($old ne $_ && exists($l->{$_})) {
Branch: 1 branch
BranchTrueFalseTotal
if ($old ne $_ and exists $l->{$_}) 0 538 538
Condition66%2/3
$old ne $_ and exists $l->{$_}
!ll&&!rl&&r
480580
MC/DC0%0/2
$old ne $_ and exists $l->{$_}
$old ne $_ exists $l->{$_}
Truth table66%2/3
A and B
A= $old ne $_B= exists $l->{$_}
ABresult
0X0
100
111
171 0 $mm->push_error("Conflict when removing prefix on left-side ".
172 "hash key: $old -> $_ but $_ already exists");
173 0 return;
174 }
175 538 $hl->{$_} = [$m2, $l->{$old}];
176 } else {
177 43 ▶ next if $esub && !$esub->($_);
Branch: 1 branch
BranchTrueFalseTotal
if $esub and not &$esub($_) 2 41 43
Condition66%2/3
$esub and not &$esub($_)
!ll&&!rl&&r
0412
MC/DC50%1/2
$esub and not &$esub($_)
$esub not &$esub($_)
Truth table66%2/3
A and not(B)
A= $esubB= not &$esub($_)
ABresult
0X0
100
111
178 41 $hl->{$_} = [$mode, $l->{$_}];
179 }
180 }
181 } else {
182 9 for (keys %$l) {
183 27 ▶ next if $esub && !$esub->($_);
Branch: 1 branch
BranchTrueFalseTotal
if $esub and not &$esub($_) 6 21 27
Condition66%2/3
$esub and not &$esub($_)
!ll&&!rl&&r
0216
MC/DC50%1/2
$esub and not &$esub($_)
$esub not &$esub($_)
Truth table66%2/3
A and not(B)
A= $esubB= not &$esub($_)
ABresult
0X0
100
111
184 21 $hl->{$_} = [$mode, $l->{$_}];
185 }
186 }
187  
188 #print "DEBUG: Leaving _gen_left, result = ".dmp($hl)."\n";
189 561 $hl;
190 }
191  
192 # turn {[prefix]key => val, ...} into { key => {MODE=>val, ...}, ...},
193 # push error if there's conflicting key+MODE
194 561 ▶sub _gen_right {
Subroutine _gen_right: called CC=26 SCAR=32.8
195 561 my ($self, $r, $mode, $esub, $ep, $ip, $epr, $ipr) = @_;
196 561 my $mm = $self->merger;
197 561 my $c = $mm->config;
198  
199 #print "DEBUG: Entering _gen_right(".dmp($r).", $mode, ...)\n";
200  
201 561 ▶ if ($c->premerge_pair_filter) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c->premerge_pair_filter) 7 554 561
202 7 $r = $self->_prefilter_hash($r, "premerge filter right hash",
203 $c->premerge_pair_filter);
204 7 ▶ return if @{ $mm->errors };
Branch: 1 branch
BranchTrueFalseTotal
if @{$mm->errors;} 0 7 7
205 }
206  
207 561 my $hr = {};
208 561 ▶ if ($c->parse_prefix) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c->parse_prefix) { } 552 9 561
209 552 for (keys %$r) {
210 1201 my $do_parse = 1;
211 1201 ▶ $do_parse = 0 if $do_parse && $ep && $mm->_in($_, $ep);
Branch: 1 branch
BranchTrueFalseTotal
if $do_parse and $ep and $mm->_in($_, $ep) 9 1192 1201
Condition83%5/6
$do_parse and $ep and $mm->_in($_, $ep)
!ll&&!rl&&r
1168249
$do_parse and $ep
!ll&&!rl&&r
0116833
MC/DC66%2/3
$do_parse and $ep and $mm->_in($_, $ep)
$do_parse $ep $mm->_in($_, $ep)
Truth table75%3/4
A and B and C
A= $do_parseB= $epC= $mm->_in($_, $ep)
ABCresult
0XX0
10X0
1100
1111
212 1201 ▶ $do_parse = 0 if $do_parse && $ip && !$mm->_in($_, $ip);
Branch: 1 branch
BranchTrueFalseTotal
if $do_parse and $ip and not $mm->_in($_, $ip) 18 1183 1201
Condition100%6/6
$do_parse and $ip and not $mm->_in($_, $ip)
!ll&&!rl&&r
11721118
$do_parse and $ip
!ll&&!rl&&r
9116329
MC/DC100%3/3
$do_parse and $ip and not $mm->_in($_, $ip)
$do_parse $ip not $mm->_in($_, $ip)
Truth table100%4/4
A and B and not(C)
A= $do_parseB= $ipC= not $mm->_in($_, $ip)
ABCresult
0XX0
10X0
1100
1111
213 1201 ▶ $do_parse = 0 if $do_parse && $epr && /$epr/;
Branch: 1 branch
BranchTrueFalseTotal
if $do_parse and $epr and /$epr/ 5 1196 1201
Condition100%6/6
$do_parse and $epr and /$epr/
!ll&&!rl&&r
1180165
$do_parse and $epr
!ll&&!rl&&r
27115321
MC/DC100%3/3
$do_parse and $epr and /$epr/
$do_parse $epr /$epr/
Truth table100%4/4
A and B and C
A= $do_parseB= $eprC= /$epr/
ABCresult
0XX0
10X0
1100
1111
214 1201 ▶ $do_parse = 0 if $do_parse && $ipr && !/$ipr/;
Branch: 1 branch
BranchTrueFalseTotal
if $do_parse and $ipr and not /$ipr/ 14 1187 1201
Condition100%6/6
$do_parse and $ipr and not /$ipr/
!ll&&!rl&&r
1181614
$do_parse and $ipr
!ll&&!rl&&r
32114920
MC/DC100%3/3
$do_parse and $ipr and not /$ipr/
$do_parse $ipr not /$ipr/
Truth table100%4/4
A and B and not(C)
A= $do_parseB= $iprC= not /$ipr/
ABCresult
0XX0
10X0
1100
1111
215  
216 1201 ▶ if ($do_parse) {
Branch: 1 branch
BranchTrueFalseTotal
if ($do_parse) { } 1155 46 1201
217 1155 my $old = $_;
218 1155 my $m2;
219 1155 ($_, $m2) = $mm->remove_prefix($_);
220 1155 ▶ next if $esub && !$esub->($_);
Branch: 1 branch
BranchTrueFalseTotal
if $esub and not &$esub($_) 605 550 1155
Condition66%2/3
$esub and not &$esub($_)
!ll&&!rl&&r
0550605
MC/DC50%1/2
$esub and not &$esub($_)
$esub not &$esub($_)
Truth table66%2/3
A and not(B)
A= $esubB= not &$esub($_)
ABresult
0X0
100
111
221 550 ▶ if (exists $hr->{$_}{$m2}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $hr->{$_}{$m2}) 0 550 550
222 0 $mm->push_error("Conflict when removing prefix on right-side ".
223 "hash key: $old($m2) -> $_ ($m2) but $_ ($m2) ".
224 "already exists");
225 0 return;
226 }
227 550 $hr->{$_}{$m2} = $r->{$old};
228 } else {
229 46 ▶ next if $esub && !$esub->($_);
Branch: 1 branch
BranchTrueFalseTotal
if $esub and not &$esub($_) 2 44 46
Condition66%2/3
$esub and not &$esub($_)
!ll&&!rl&&r
0442
MC/DC50%1/2
$esub and not &$esub($_)
$esub not &$esub($_)
Truth table66%2/3
A and not(B)
A= $esubB= not &$esub($_)
ABresult
0X0
100
111
230 44 $hr->{$_} = {$mode => $r->{$_}};
231 }
232 }
233 } else {
234 9 for (keys %$r) {
235 25 ▶ next if $esub && !$esub->($_);
Branch: 1 branch
BranchTrueFalseTotal
if $esub and not &$esub($_) 5 20 25
Condition66%2/3
$esub and not &$esub($_)
!ll&&!rl&&r
0205
MC/DC50%1/2
$esub and not &$esub($_)
$esub not &$esub($_)
Truth table66%2/3
A and not(B)
A= $esubB= not &$esub($_)
ABresult
0X0
100
111
236 20 $hr->{$_} = {$mode => $r->{$_}}
237 }
238 }
239 #print "DEBUG: Leaving _gen_right, result = ".dmp($hr)."\n";
240 561 $hr;
241 }
242  
243 # merge two hashes which have been prepared by _gen_left and
244 # _gen_right, will result in { key => [final_mode, val], ... }
245 554 ▶sub _merge_gen {
Subroutine _merge_gen: called CC=35 SCAR=35.6
246 554 my ($self, $hl, $hr, $mode, $em, $im, $emr, $imr) = @_;
247 554 my $mm = $self->merger;
248 554 my $c = $mm->config;
249  
250 #print "DEBUG: Entering _merge_gen(".dmp($hl).", ".dmp($hr).", $mode, ...)\n";
251  
252 554 my $res = {};
253 554 my $backup = {};
254  
255 554 my %k = map {$_=>1} keys(%$hl), keys(%$hr);
256 554 push @{ $mm->path }, "";
257 K:
258 554 for my $k (keys %k) {
259 706 my @o;
260 706 $mm->path->[-1] = $k;
261 706 my $do_merge = 1;
262 706 ▶ $do_merge = 0 if $do_merge && $em && $mm->_in($k, $em);
Branch: 1 branch
BranchTrueFalseTotal
if $do_merge and $em and $mm->_in($k, $em) 6 700 706
Condition83%5/6
$do_merge and $em and $mm->_in($k, $em)
!ll&&!rl&&r
682186
$do_merge and $em
!ll&&!rl&&r
068224
MC/DC66%2/3
$do_merge and $em and $mm->_in($k, $em)
$do_merge $em $mm->_in($k, $em)
Truth table75%3/4
A and B and C
A= $do_mergeB= $emC= $mm->_in($k, $em)
ABCresult
0XX0
10X0
1100
1111
263 706 ▶ $do_merge = 0 if $do_merge && $im && !$mm->_in($k, $im);
Branch: 1 branch
BranchTrueFalseTotal
if $do_merge and $im and not $mm->_in($k, $im) 15 691 706
Condition100%6/6
$do_merge and $im and not $mm->_in($k, $im)
!ll&&!rl&&r
683815
$do_merge and $im
!ll&&!rl&&r
667723
MC/DC100%3/3
$do_merge and $im and not $mm->_in($k, $im)
$do_merge $im not $mm->_in($k, $im)
Truth table100%4/4
A and B and not(C)
A= $do_mergeB= $imC= not $mm->_in($k, $im)
ABCresult
0XX0
10X0
1100
1111
264 706 ▶ $do_merge = 0 if $do_merge && $emr && $k =~ /$emr/;
Branch: 1 branch
BranchTrueFalseTotal
if $do_merge and $emr and $k =~ /$emr/ 14 692 706
Condition100%6/6
$do_merge and $emr and $k =~ /$emr/
!ll&&!rl&&r
6682414
$do_merge and $emr
!ll&&!rl&&r
2164738
MC/DC100%3/3
$do_merge and $emr and $k =~ /$emr/
$do_merge $emr $k =~ /$emr/
Truth table100%4/4
A and B and C
A= $do_mergeB= $emrC= $k =~ /$emr/
ABCresult
0XX0
10X0
1100
1111
265 706 ▶ $do_merge = 0 if $do_merge && $imr && $k !~ /$imr/;
Branch: 1 branch
BranchTrueFalseTotal
if $do_merge and $imr and not $k =~ /$imr/ 12 694 706
Condition100%6/6
$do_merge and $imr and not $k =~ /$imr/
!ll&&!rl&&r
6841012
$do_merge and $imr
!ll&&!rl&&r
3564922
MC/DC100%3/3
$do_merge and $imr and not $k =~ /$imr/
$do_merge $imr not $k =~ /$imr/
Truth table100%4/4
A and B and not(C)
A= $do_mergeB= $imrC= not $k =~ /$imr/
ABCresult
0XX0
10X0
1100
1111
266  
267 706 ▶ if (!$do_merge) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($do_merge) 47 659 706
268 47 ▶ $res->{$k} = $hl->{$k} if $hl->{$k};
Branch: 1 branch
BranchTrueFalseTotal
if $hl->{$k} 45 2 47
269 47 next K;
270 }
271  
272 659 ▶ $backup->{$k} = $hl->{$k}[1] if $hl->{$k} && $hr->{$k};
Branch: 1 branch
BranchTrueFalseTotal
if $hl->{$k} and $hr->{$k} 435 224 659
Condition100%3/3
$hl->{$k} and $hr->{$k}
!ll&&!rl&&r
106118435
MC/DC100%2/2
$hl->{$k} and $hr->{$k}
$hl->{$k} $hr->{$k}
Truth table100%3/3
A and B
A= $hl->{$k}B= $hr->{$k}
ABresult
0X0
100
111
273 659 ▶ if ($hl->{$k}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hl->{$k}) 553 106 659
274 553 push @o, $hl->{$k};
275 }
276 659 ▶ if ($hr->{$k}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hr->{$k}) 541 118 659
277 541 my %m = map {$_=>$mm->modes->{$_}->precedence_level} keys %{ $hr->{$k} };
278 #print "DEBUG: \\%m=".Data::Dumper->new([\%m])->Indent(0)->Terse(1)->Dump."\n";
279 541 push @o, map { [$_, $hr->{$k}{$_}] } sort { $m{$b} <=> $m{$a} } keys %m;
280 }
281 659 my $final_mode;
282 my $is_circular;
283 659 my $v;
284 #print "DEBUG: k=$k, o=".Data::Dumper->new([\@o])->Indent(0)->Terse(1)->Dump."\n";
285 659 for my $i (0..$#o) {
286 1112 ▶ if ($i == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i == 0) { } 659 453 1112
287 659 my $mh = $mm->modes->{$o[$i][0]};
288 659 ▶ if (@o == 1 &&
Branch: 1 branch
BranchTrueFalseTotal
if (@o == 1 and $hl->{$k} && $mh->can('merge_left_only') || $hr->{$k} && $mh->can('merge_right_only')) { } 3 656 659
Condition100%12/12
@o == 1 and $hl->{$k} && $mh->can("merge_left_only") || $hr->{$k} && $mh->can("merge_right_only")
!ll&&!rl&&r
4352213
$hl->{$k} and $mh->can("merge_left_only") or $hr->{$k} and $mh->can("merge_right_only")
l!l&&r!l&&!r
12221
$hl->{$k} and $mh->can("merge_left_only")
!ll&&!rl&&r
1061171
$hr->{$k} and $mh->can("merge_right_only")
!ll&&!rl&&r
1171042
MC/DC80%4/5
@o == 1 and $hl->{$k} && $mh->can("merge_left_only") || $hr->{$k} && $mh->can("merge_right_only")
@o == 1 $hl->{$k} $mh->can("merge_left_only") $hr->{$k} $mh->can("merge_right_only")
Truth table62%5/8
A and B and C or D and E
A= @o == 1B= $hl->{$k}C= $mh->can("merge_left_only")D= $hr->{$k}E= $mh->can("merge_right_only")
ABCDEresult
0XXXX0
10X0X0
10X100
1100X0
110100
111XX1
10X111
110111
289 (($hl->{$k} && $mh->can("merge_left_only")) ||
290 ($hr->{$k} && $mh->can("merge_right_only")))) {
291 # there's only left-side or right-side
292 3 ▶ my $meth = $hl->{$k} ? "merge_left_only" : "merge_right_only";
Branch: 1 branch
BranchTrueFalseTotal
$hl->{$k} ? : 1 2 3
293 3 my ($subnewkey, $v1, $subbackup, $is_circular, $newmode) = $mh->$meth($k, $o[$i][1]); # XXX handle circular?
294 3 ▶ next K unless defined($subnewkey);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $subnewkey 3 0 3
295 0 $final_mode = $newmode;
296 0 $v = $v1;
297 } else {
298 656 $final_mode = $o[$i][0];
299 656 $v = $o[$i][1];
300 }
301 } else {
302 my $m = $mm->combine_rules->{"$final_mode+$o[$i][0]"}
303 453 ▶ or do {
Branch: 1 branch
BranchTrueFalseTotal
my $m = $mm->combine_rules->{"$final_mode+$o[$i][0]"} or do { $mm->push_error("Can't merge $final_mode + $o[$i][0]"); return } 445 8 453
304 8 $mm->push_error("Can't merge $final_mode + $o[$i][0]");
305 8 return;
306 };
307 #print "DEBUG: merge $final_mode+$o[$i][0] = $m->[0], $m->[1]\n";
308 445 my ($subnewkey, $subbackup);
309 445 ($subnewkey, $v, $subbackup, $is_circular) = $mm->_merge($k, $v, $o[$i][1], $m->[0]);
310 445 ▶ return if @{ $mm->errors };
Branch: 1 branch
BranchTrueFalseTotal
if @{$mm->errors;} 36 409 445
311 409 ▶ if ($is_circular) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_circular) 3 406 409
312 3 ▶ if ($i < $#o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $#o) 1 2 3
313 1 $mm->push_error("Can't handle circular at $i of $#o merges (mode $m->[0]): not the last merge");
314 1 return;
315 }
316 #print "DEBUG: pushing todo to mem<".$mm->cur_mem_key.">\n";
317 2 ▶ push @{ $mm->mem->{ $mm->cur_mem_key }{todo} }, sub {
Subroutine __ANON__: called CC=2 SCAR=7.1
318 2 my ($subnewkey, $subres, $subbackup) = @_;
319 #print "DEBUG: Entering todo subroutine (k=$k)\n";
320 2 my $final_mode = $m->[1];
321 #XXX return unless defined($subnewkey);
322 2 $res->{$k} = [$m->[1], $subres];
323 2 ▶ if ($c->readd_prefix) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c->readd_prefix) { } 2 0 2
324 # XXX if there is a conflict error in
325 # _readd_prefix, how to adjust path?
326 2 $self->_readd_prefix($res, $k, $c->default_mode);
327 } else {
328 0 $res->{$k} = $res->{$k}[1];
329 }
330 2 };
331 2 delete $res->{$k};
332 }
333 408 ▶ next K unless defined $subnewkey;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $subnewkey 57 351 408
334 351 $final_mode = $m->[1];
335 }
336 }
337 554 ▶ $res->{$k} = [$final_mode, $v] unless $is_circular;
Branch: 1 branch
BranchTrueFalseTotal
unless $is_circular 552 2 554
338 }
339 509 pop @{ $mm->path };
340 #print "DEBUG: Leaving _merge_gen, res = ".dmp($res)."\n";
341 509 ($res, $backup);
342 }
343  
344 # hh is {key=>[MODE, val], ...} which is the format returned by _merge_gen
345 508 ▶sub _readd_prefix {
Subroutine _readd_prefix: called CC=3 SCAR=11.2
346 508 my ($self, $hh, $k, $defmode) = @_;
347 508 my $mm = $self->merger;
348 508 my $c = $mm->config;
349  
350 508 my $m = $hh->{$k}[0];
351 508 ▶ if ($m eq $defmode) {
Branch: 1 branch
BranchTrueFalseTotal
if ($m eq $defmode) { } 443 65 508
352 443 $hh->{$k} = $hh->{$k}[1];
353 } else {
354 65 my $kp = $mm->modes->{$m}->add_prefix($k);
355 65 ▶ if (exists $hh->{$kp}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $hh->{$kp}) 0 65 65
356 0 $mm->push_error("BUG: conflict when re-adding prefix after merge: $kp");
357 0 return;
358 }
359 65 $hh->{$kp} = $hh->{$k}[1];
360 65 delete $hh->{$k};
361 }
362 }
363  
364 304 ▶sub merge_HASH_HASH {
Subroutine merge_HASH_HASH: called CC=51 SCAR=39.3
Pod undocumented
365 304 my ($self, $key, $l, $r, $mode) = @_;
366 304 my $mm = $self->merger;
367 304 my $c = $mm->config;
368 304 ▶ $mode //= $c->default_mode;
Condition66%2/3
$mode //= $c->default_mode
l!l&&r!l&&!r
62980
MC/DC0%0/2
$mode //= $c->default_mode
$mode $c->default_mode
Truth table66%2/3
A //= B
A= $modeB= $c->default_mode
ABresult
1X1
011
000
369 #print "DEBUG: entering merge_H_H(".dmp($l).", ".dmp($r).", $mode), config=($c)=",dmp($c),"\n";
370 #$log->trace("using config($c)");
371  
372 304 ▶ return $self->merge_SCALAR_SCALAR($key, $l, $r) unless $c->recurse_hash;
Branch: 1 branch
BranchTrueFalseTotal
unless $c->recurse_hash 4 300 304
373 300 ▶ return if $c->wanted_path && !$mm->_path_is_included($mm->path, $c->wanted_path);
Branch: 1 branch
BranchTrueFalseTotal
if $c->wanted_path and not $mm->_path_is_included($mm->path, $c->wanted_path) 2 298 300
Condition100%3/3
$c->wanted_path and not $mm->_path_is_included($mm->path, $c->wanted_path)
!ll&&!rl&&r
29532
MC/DC100%2/2
$c->wanted_path and not $mm->_path_is_included($mm->path, $c->wanted_path)
$c->wanted_path not $mm->_path_is_included($mm->path, $c->wanted_path)
Truth table100%3/3
A and not(B)
A= $c->wanted_pathB= not $mm->_path_is_included($mm->path, $c->wanted_path)
ABresult
0X0
100
111
374  
375 # STEP 1. MERGE LEFT & RIGHT OPTIONS KEY
376 298 my $config_replaced;
377 298 my $orig_c = $c;
378 298 my $ok = $c->options_key;
379 {
380 298 ▶ last unless defined $ok;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $ok 1 297 298
381  
382 297 ▶ my $okl = $self->_gen_left ($l, $mode, sub {$_[0] eq $ok});
Subroutine __ANON__: called CC=1 SCAR=0.0
383 296 ▶ return if @{ $mm->errors };
Branch: 1 branch
BranchTrueFalseTotal
if @{$mm->errors;} 4 292 296
384  
385 292 ▶ my $okr = $self->_gen_right($r, $mode, sub {$_[0] eq $ok});
Subroutine __ANON__: called CC=1 SCAR=0.0
386 292 ▶ return if @{ $mm->errors };
Branch: 1 branch
BranchTrueFalseTotal
if @{$mm->errors;} 0 292 292
387  
388 292 push @{ $mm->path }, $ok;
389 292 my ($res, $backup);
390 {
391 292 local $c->{readd_prefix} = 0;
392 292 ($res, $backup) = $self->_merge_gen($okl, $okr, $mode);
393 }
394 292 pop @{ $mm->path };
395 292 ▶ return if @{ $mm->errors };
Branch: 1 branch
BranchTrueFalseTotal
if @{$mm->errors;} 1 291 292
396  
397 #print "DEBUG: merge options key (".dmp($okl).", ".dmp($okr).") = ".dmp($res)."\n";
398  
399 291 ▶ $res = $res->{$ok} ? $res->{$ok}[1] : undef;
Branch: 1 branch
BranchTrueFalseTotal
$res->{$ok} ? : 72 219 291
400 291 ▶ if (defined($res) && ref($res) ne 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $res and ref $res ne "HASH") 6 285 291
Condition100%3/3
defined $res and ref $res ne "HASH"
!ll&&!rl&&r
219666
MC/DC100%2/2
defined $res and ref $res ne "HASH"
defined $res ref $res ne "HASH"
Truth table100%3/3
A and B
A= defined $resB= ref $res ne "HASH"
ABresult
0X0
100
111
401 6 $mm->push_error("Invalid options key after merge: value must be hash");
402 6 return;
403 }
404 285 ▶ last unless keys %$res;
Branch: 1 branch
BranchTrueFalseTotal
unless keys %$res 223 62 285
405 #$log->tracef("cloning config ...");
406 # Data::Clone by default does *not* deep-copy object
407 #my $c2 = clone($c);
408 62 my $c2 = bless({ %$c }, ref($c));
409  
410 62 for (keys %$res) {
411 62 ▶ if ($c->allow_override) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c->allow_override) 5 57 62
412 5 my $re = $c->allow_override;
413 5 ▶ if (!/$re/) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/$re/) 2 3 5
414 2 $mm->push_error("Configuration in options key `$_` not allowed by allow_override $re");
415 2 return;
416 }
417 }
418 60 ▶ if ($c->disallow_override) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c->disallow_override) 4 56 60
419 4 my $re = $c->disallow_override;
420 4 ▶ if (/$re/) {
Branch: 1 branch
BranchTrueFalseTotal
if (/$re/) 2 2 4
421 2 $mm->push_error("Configuration in options key `$_` not allowed by disallow_override $re");
422 2 return;
423 }
424 }
425 58 ▶ if ($mm->_in($_, $c->_config_config)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mm->_in($_, $c->_config_config)) 4 54 58
426 4 $mm->push_error("Configuration not allowed in options key: $_");
427 4 return;
428 }
429 54 ▶ if ($_ ne $ok && !$mm->_in($_, $c->_config_ok)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_ ne $ok and not $mm->_in($_, $c->_config_ok)) 1 53 54
Condition66%2/3
$_ ne $ok and not $mm->_in($_, $c->_config_ok)
!ll&&!rl&&r
0531
MC/DC50%1/2
$_ ne $ok and not $mm->_in($_, $c->_config_ok)
$_ ne $ok not $mm->_in($_, $c->_config_ok)
Truth table66%2/3
A and not(B)
A= $_ ne $okB= not $mm->_in($_, $c->_config_ok)
ABresult
0X0
100
111
430 1 $mm->push_error("Unknown configuration in options key: $_");
431 1 return;
432 }
433 53 ▶ $c2->$_($res->{$_}) unless $_ eq $ok;
Branch: 1 branch
BranchTrueFalseTotal
unless $_ eq $ok 53 0 53
434 }
435 53 $mm->config($c2);
436 53 $config_replaced++;
437 53 $c = $c2;
438 #$log->trace("config now changed to $c2");
439 }
440  
441 277 my $sp = $c->set_prefix;
442 277 my $saved_prefixes;
443 277 ▶ if (defined($sp)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $sp) 7 270 277
444 7 ▶ if (ref($sp) ne 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $sp ne "HASH") 2 5 7
445 2 $mm->push_error("Invalid config value `set_prefix`: must be a hash");
446 2 return;
447 }
448 5 $saved_prefixes = {};
449 5 for my $mh (values %{ $mm->modes }) {
450 30 my $n = $mh->name;
451 30 ▶ if ($sp->{$n}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sp->{$n}) 7 23 30
452 7 $saved_prefixes->{$n} = {
453 prefix => $mh->prefix,
454 prefix_re => $mh->prefix_re,
455 check_prefix_sub => $mh->check_prefix_sub,
456 add_prefix_sub => $mh->add_prefix_sub,
457 remove_prefix_sub => $mh->remove_prefix_sub,
458 };
459 7 $mh->prefix($sp->{$n});
460 7 my $re = quotemeta($sp->{$n});
461 7 $mh->prefix_re(qr/^$re/);
462 7 $mh->check_prefix_sub(undef);
463 7 $mh->add_prefix_sub(undef);
464 7 $mh->remove_prefix_sub(undef);
465 }
466 }
467 }
468  
469 275 my $ep = $c->exclude_parse;
470 275 my $ip = $c->include_parse;
471 275 ▶ if (defined($ep) && ref($ep) ne 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ep and ref $ep ne "ARRAY") 2 273 275
Condition100%3/3
defined $ep and ref $ep ne "ARRAY"
!ll&&!rl&&r
26582
MC/DC100%2/2
defined $ep and ref $ep ne "ARRAY"
defined $ep ref $ep ne "ARRAY"
Truth table100%3/3
A and B
A= defined $epB= ref $ep ne "ARRAY"
ABresult
0X0
100
111
472 2 $mm->push_error("Invalid config value `exclude_parse`: must be an array");
473 2 return;
474 }
475 273 ▶ if (defined($ip) && ref($ip) ne 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ip and ref $ip ne "ARRAY") 2 271 273
Condition100%3/3
defined $ip and ref $ip ne "ARRAY"
!ll&&!rl&&r
26472
MC/DC100%2/2
defined $ip and ref $ip ne "ARRAY"
defined $ip ref $ip ne "ARRAY"
Truth table100%3/3
A and B
A= defined $ipB= ref $ip ne "ARRAY"
ABresult
0X0
100
111
476 2 $mm->push_error("Invalid config value `include_parse`: must be an array");
477 2 return;
478 }
479  
480 271 my $epr = $c->exclude_parse_regex;
481 271 my $ipr = $c->include_parse_regex;
482 271 ▶ if (defined($epr)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $epr) 5 266 271
483 5 eval { $epr = qr/$epr/ };
484 5 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 1 4 5
485 1 $mm->push_error("Invalid config value `exclude_parse_regex`: invalid regex: $@");
486 1 return;
487 }
488 }
489 270 ▶ if (defined($ipr)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ipr) 5 265 270
490 5 eval { $ipr = qr/$ipr/ };
491 5 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 1 4 5
492 1 $mm->push_error("Invalid config value `include_parse_regex`: invalid regex: $@");
493 1 return;
494 }
495 }
496  
497 # STEP 2. PREPARE LEFT HASH
498 269 ▶ my $hl = $self->_gen_left ($l, $mode, sub {defined($ok) ? $_[0] ne $ok : 1}, $ep, $ip, $epr, $ipr);
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
defined $ok ? : 583 3 586
499 269 ▶ return if @{ $mm->errors };
Branch: 1 branch
BranchTrueFalseTotal
if @{$mm->errors;} 0 269 269
500  
501 # STEP 3. PREPARE RIGHT HASH
502 269 ▶ my $hr = $self->_gen_right($r, $mode, sub {defined($ok) ? $_[0] ne $ok : 1}, $ep, $ip, $epr, $ipr);
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
defined $ok ? : 598 2 600
503 269 ▶ return if @{ $mm->errors };
Branch: 1 branch
BranchTrueFalseTotal
if @{$mm->errors;} 0 269 269
504  
505 #print "DEBUG: hl=".Data::Dumper->new([$hl])->Indent(0)->Terse(1)->Dump."\n";
506 #print "DEBUG: hr=".Data::Dumper->new([$hr])->Indent(0)->Terse(1)->Dump."\n";
507  
508 269 my $em = $c->exclude_merge;
509 269 my $im = $c->include_merge;
510 269 ▶ if (defined($em) && ref($em) ne 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $em and ref $em ne "ARRAY") 2 267 269
Condition100%3/3
defined $em and ref $em ne "ARRAY"
!ll&&!rl&&r
26162
MC/DC100%2/2
defined $em and ref $em ne "ARRAY"
defined $em ref $em ne "ARRAY"
Truth table100%3/3
A and B
A= defined $emB= ref $em ne "ARRAY"
ABresult
0X0
100
111
511 2 $mm->push_error("Invalid config value `exclude_marge`: must be an array");
512 2 return;
513 }
514 267 ▶ if (defined($im) && ref($im) ne 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $im and ref $im ne "ARRAY") 2 265 267
Condition100%3/3
defined $im and ref $im ne "ARRAY"
!ll&&!rl&&r
25962
MC/DC100%2/2
defined $im and ref $im ne "ARRAY"
defined $im ref $im ne "ARRAY"
Truth table100%3/3
A and B
A= defined $imB= ref $im ne "ARRAY"
ABresult
0X0
100
111
515 2 $mm->push_error("Invalid config value `include_merge`: must be an array");
516 2 return;
517 }
518  
519 265 my $emr = $c->exclude_merge_regex;
520 265 my $imr = $c->include_merge_regex;
521 265 ▶ if (defined($emr)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $emr) 13 252 265
522 13 eval { $emr = qr/$emr/ };
523 13 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 2 11 13
524 2 $mm->push_error("Invalid config value `exclude_merge_regex`: invalid regex: $@");
525 2 return;
526 }
527 }
528 263 ▶ if (defined($imr)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $imr) 7 256 263
529 7 eval { $imr = qr/$imr/ };
530 7 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 1 6 7
531 1 $mm->push_error("Invalid config value `include_merge_regex`: invalid regex: $@");
532 1 return;
533 }
534 }
535  
536 # STEP 4. MERGE LEFT & RIGHT
537 262 my ($res, $backup) = $self->_merge_gen($hl, $hr, $mode, $em, $im, $emr, $imr);
538 262 ▶ return if @{ $mm->errors };
Branch: 1 branch
BranchTrueFalseTotal
if @{$mm->errors;} 44 218 262
539  
540 #print "DEBUG: intermediate res(5) = ".Data::Dumper->new([$res])->Indent(0)->Terse(1)->Dump."\n";
541  
542 # STEP 5. TURN BACK {key=>[MODE=>val]}, ...} INTO {(prefix)key => val, ...}
543 218 ▶ if ($c->readd_prefix) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c->readd_prefix) { } 197 21 218
544 197 for my $k (keys %$res) {
545 506 $self->_readd_prefix($res, $k, $c->default_mode);
546 }
547 } else {
548 21 $res->{$_} = $res->{$_}[1] for keys %$res;
549 }
550  
551 218 ▶ if ($saved_prefixes) {
Branch: 1 branch
BranchTrueFalseTotal
if ($saved_prefixes) 5 213 218
552 5 for (keys %$saved_prefixes) {
553 7 my $mh = $mm->modes->{$_};
554 7 my $s = $saved_prefixes->{$_};
555 7 $mh->prefix($s->{prefix});
556 7 $mh->prefix_re($s->{prefix_re});
557 7 $mh->check_prefix_sub($s->{check_prefix_sub});
558 7 $mh->add_prefix_sub($s->{add_prefix_sub});
559 7 $mh->remove_prefix_sub($s->{remove_prefix_sub});
560 }
561 }
562  
563 # restore config
564 218 ▶ if ($config_replaced) {
Branch: 1 branch
BranchTrueFalseTotal
if ($config_replaced) 44 174 218
565 44 $mm->config($orig_c);
566 #print "DEBUG: Restored config, config=", dmp($mm->config), "\n";
567 }
568  
569 #print "DEBUG: backup = ".Data::Dumper->new([$backup])->Indent(0)->Terse(1)->Dump."\n";
570 #print "DEBUG: leaving merge_H_H, result = ".dmp($res)."\n";
571 218 ($key, $res, $backup);
572 }
573  
574 38 1;
575 # ABSTRACT: Base class for Data::ModeMerge mode handler
576  
577 __END__
↑ Summary ModeMerge.pm »