Lite.pm

filter: Statementstmt 89.2% 175 / 196 Branchbran 70.4% 69 / 98 Conditioncond 76.2% 45 / 59 MC/DCmcdc 48.4% 16 / 33 Subroutinesub 91.6% 22 / 24 Podpod 100% 9 / 9 totaltotal 80.1% 336 / 419 CC 77 SCAR 29.5
CC
77
Cov
82%
merge
37.5
new
26.1
_equal
20.0
CRAP 19.1
« Lite/Delta.pm ↑ Summary
1 package VCS::Lite;
2  
3 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 9 our $VERSION = '0.11';
6  
7 #----------------------------------------------------------------------------
8  
9 =head1 NAME
10  
11 VCS::Lite - Minimal version control system
12  
13 =head1 SYNOPSIS
14  
15 use VCS::Lite;
16  
17 # diff
18  
19 my $lit = VCS::Lite->new('/home/me/foo1.txt');
20 my $lit2 = VCS::Lite->new('/home/me/foo2.txt');
21 my $difftxt = $lit->delta($lit2)->diff;
22 print OUTFILE $difftxt;
23  
24 # patch
25  
26 my $delt = VCS::Lite::Delta->new('/home/me/patch.diff');
27 my $lit3 = $lit->patch($delt);
28 print OUTFILE $lit3->text;
29  
30 # merge
31  
32 my $lit4 = $lit->merge($lit->delta($lit2),$lit->delta($lit3));
33 print OUTFILE $lit4->text;
34  
35 =head1 DESCRIPTION
36  
37 This module provides the functions normally associated with a version
38 control system, but without needing or implementing a version control
39 system. Applications include wikis, document management systems and
40 configuration management.
41  
42 It makes use of the module Algorithm::Diff. It provides the facility
43 for basic diffing, patching and merging.
44  
45 =cut
46  
47 #----------------------------------------------------------------------------
48  
49 #############################################################################
50 #Library Modules #
51 #############################################################################
52  
53 9 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
54 9 ▶use Algorithm::Diff qw(traverse_sequences);
Subroutine BEGIN: called CC=1 SCAR=0.0
55 9 ▶use VCS::Lite::Delta;
Subroutine BEGIN: called CC=1 SCAR=0.0
56  
57 #----------------------------------------------------------------------------
58  
59 #############################################################################
60 #Interface Methods #
61 #############################################################################
62  
63 sub new {
64 37 ▶ my ($class,$id,$sep,$src,@args) = @_;
Subroutine new: called CC=18 SCAR=32.6
Pod documented
65  
66 37 my %proto = ();
67  
68 # Decode $sep as needed
69  
70 37 ▶ if (ref($sep) eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $sep eq "HASH") 10 27 37
71 10 %proto = %$sep;
72 10 $sep = $proto{in};
73 10 delete $proto{in};
74 }
75
76 # DWIM logic, based on $src parameter.
77  
78 # Case 0: $src missing. Use $id as file name, becomes case 3
79 37 ▶ open $src,$id or croak("failed to open '$id': $!") unless $src;
Branch: 1 branch
BranchTrueFalseTotal
unless $src 20 17 37
Condition50%3/6
$src || (open($src, $id) || croak("failed to open '${id}': $!"))
l!l&&r!l&&!r
17200
open $src, $id or croak("failed to open '${id}': $!")
l!l&&r!l&&!r
2000
MC/DC0%0/3
$src || (open($src, $id) || croak("failed to open '${id}': $!"))
$src open $src, $id croak("failed to open '${id}': $!")
Truth table0%0/4
A || B or C
A= $srcB= open $src, $idC= croak("failed to open '${id}': $!")
ABCresult
1XX1
01X1
0011
0000
80
81 37 my $atyp = ref $src;
82 37 ▶ $sep ||= $/;
Condition66%2/3
$sep ||= $/
l!l&&r!l&&!r
9280
MC/DC0%0/2
$sep ||= $/
$sep $/
Truth table66%2/3
A ||= B
A= $sepB= $/
ABresult
1X1
011
000
83 37 ▶ local $/ = $sep if $sep;
Branch: 1 branch
BranchTrueFalseTotal
if $sep 37 0 37
84 37 ▶ $proto{out} ||= $\ || '';
Condition60%3/5
$proto{"out"} ||= $\ || ""
l!l&&r!l&&!r
2035
$\ || ''
l!l
035
MC/DC50%1/2
$proto{"out"} ||= $\ || ""
$proto{"out"} $\
Truth table66%2/3
A ||= B
A= $proto{"out"}B= $\
ABresult
1X1
011
000
85 37 my $out_sep = $proto{out};
86 37 my @contents;
87  
88 # Case 1: $src is string
89 37 ▶ if (!$atyp) {
Branch: 4 branches
BranchTrueFalseTotal
if (not $atyp) { } 0 37 37
elsif ($atyp eq 'ARRAY') { } 17 20 37
elsif ($atyp eq 'GLOB') { } 20 0 20
elsif ($atyp eq 'CODE') { } 0 0 0
90 0 @contents = split /(?=$sep)/,$src;
91 }
92 # Case 2: $src is arrayref
93 elsif ($atyp eq 'ARRAY') {
94 17 @contents = @$src;
95 }
96 # Case 3: $src is globref (file handle)
97 elsif ($atyp eq 'GLOB') {
98 20 @contents = <$src>;
99 }
100 # Case 4: $src is coderef - callback
101 elsif ($atyp eq 'CODE') {
102 0 ▶ while (my $item=&$src(@args)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $item = &$src(@args)) 0 0 0
103 0 push @contents,$item;
104 }
105 }
106 # Case otherwise is an error.
107 else {
108 0 croak "Invalid argument";
109 }
110
111 37 ▶ $proto{last_line_short} = 1
Branch: 1 branch
BranchTrueFalseTotal
if @contents and not $contents[-1] =~ /$sep$/ 8 29 37
Condition66%2/3
@contents and not $contents[-1] =~ /$sep$/
!ll&&!rl&&r
0298
MC/DC50%1/2
@contents and not $contents[-1] =~ /$sep$/
@contents not $contents[-1] =~ /$sep$/
Truth table66%2/3
A and not(B)
A= @contentsB= not $contents[-1] =~ /$sep$/
ABresult
0X0
100
111
112 if @contents && ($contents[-1] !~ /$sep$/);
113
114 37 ▶ if ($proto{chomp}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($proto{"chomp"}) 6 31 37
115 6 s/$sep$//s for @contents;
116 6 ▶ $proto{out} ||= $sep;
Condition66%2/3
$proto{"out"} ||= $sep
l!l&&r!l&&!r
240
MC/DC0%0/2
$proto{"out"} ||= $sep
$proto{"out"} $sep
Truth table66%2/3
A ||= B
A= $proto{"out"}B= $sep
ABresult
1X1
011
000
117 }
118
119 37 bless { id => $id,
120 contents => \@contents,
121 separator => $sep,
122 %proto },$class;
123 }
124  
125 sub original {
126 2 ▶ my $self = shift;
Subroutine original: called CC=2 SCAR=7.1
Pod documented
127  
128 2 my $pkg = ref $self;
129  
130 exists($self->{original}) ?
131 bless ({ id => $self->id,
132 contents => $self->{original},
133 separator => $self->{separator},
134 out => $self->{out},
135 chomp => $self->{chomp},
136 2 ▶ }, $pkg ) :
Branch: 1 branch
BranchTrueFalseTotal
exists $self->{'original'} ? : 2 0 2
137 $self;
138 }
139  
140 sub apply {
141 3 ▶ my ($self,$other,%par) = @_;
Subroutine apply: called CC=5 SCAR=16.2
Pod documented
142  
143 3 my $pkg = ref $self;
144 3 my $base = $par{base};
145 3 ▶ $base ||= 'contents';
Condition100%2/2
$base ||= "contents"
l!l
12
MC/DC100%1/1
$base ||= "contents"
$base
Truth table100%2/2
A
A= $base
Aresult
11
00
146 $base = $pkg->new( $self->id,
147 $self->{separator},
148 3 ▶ $self->{$base})
Branch: 1 branch
BranchTrueFalseTotal
unless ref $base 3 0 3
149 unless ref $base;
150 3 ▶ my $cbase = exists($other->{original}) ? $other->original : $base;
Branch: 1 branch
BranchTrueFalseTotal
exists $other->{'original'} ? : 1 2 3
151 3 my $mrg = $cbase->merge($base,$other);
152 3 my $mrg2 = $base->merge($self,$mrg);
153 3 ▶ $self->{original} ||= $self->{contents};
Condition66%2/3
$self->{"original"} ||= $self->{"contents"}
l!l&&r!l&&!r
120
MC/DC0%0/2
$self->{"original"} ||= $self->{"contents"}
$self->{"original"} $self->{"contents"}
Truth table66%2/3
A ||= B
A= $self->{"original"}B= $self->{"contents"}
ABresult
1X1
011
000
154 3 $self->{contents} = [$mrg2->text];
155 }
156
157 sub text {
158 40 ▶ my ($self,$sep) = @_;
Subroutine text: called CC=4 SCAR=13.9
Pod documented
159
160 40 ▶ $sep ||= $self->{out} || '';
Condition80%4/5
$sep ||= $self->{"out"} || ""
l!l&&r!l&&!r
0337
$self->{'out'} || ''
l!l
337
MC/DC50%1/2
$sep ||= $self->{"out"} || ""
$sep $self->{'out'}
Truth table66%2/3
A ||= B
A= $sepB= $self->{'out'}
ABresult
1X1
011
000
161  
162 40 ▶ wantarray ? @{$self->{contents}} : join $sep,@{$self->{contents}};
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 27 13 40
163 }
164  
165 sub id {
166 26 ▶ my $self = shift;
Subroutine id: called CC=2 SCAR=7.2
Pod documented
167  
168 26 ▶ @_ ? ($self->{id} = shift) : $self->{id};
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 26 26
169 }
170  
171 sub delta {
172 9 ▶ my $lite1 = shift;
Subroutine delta: called CC=3 SCAR=11.0
Pod documented
173 9 my $lite2 = shift;
174 9 my %par = @_;
175
176 9 my @wl1 = $lite1->_window($par{window});
177 9 my @wl2 = $lite2->_window($par{window});
178 29 my @d = map { [map { [$_->[0] . ($_->[2]{short} ? '/' : ''),
179 175 ▶ $_->[1], $_->[2]{line} ] } @$_ ] }
Branch: 1 branch
BranchTrueFalseTotal
$_->[2]{'short'} ? : 2 173 175
180 1627 ▶ Algorithm::Diff::diff(\@wl1,\@wl2,sub { $_[0]{window}; })
Subroutine __ANON__: called CC=1 SCAR=0.0
181 9 ▶ or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my(@d) = map({[map({[$_->[0] . ($_->[2]{"short"} ? "/" : ""), $_->[1], $_->[2]{"line"}];} @$_)];} Algorithm::Diff::diff(\@wl1, \@wl2, sub { $_[0]{"window"}; } )) or return undef 2 7 9
182  
183 7 VCS::Lite::Delta->new(\@d,$lite1->id,$lite2->id,$lite1->{out});
184 }
185  
186 sub _window {
187 18 ▶ my $self = shift;
Subroutine _window: called CC=10 SCAR=23.0
188  
189 18 ▶ my $win = shift || 0;
Condition100%2/2
shift() || 0
l!l
414
MC/DC100%1/1
shift() || 0
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
190 18 ▶ my ($win_from,$win_to) = ref($win) ? (-$win->[0],$win->[1]) :
Branch: 1 branch
BranchTrueFalseTotal
ref $win ? : 0 18 18
191 (-$win,$win);
192 18 my @wintxt;
193 18 my $max = $#{$self->{contents}};
194 18 for (0..$max) {
195 1599 my $win_lb = $_ + $win_from;
196 1599 ▶ $win_lb = 0 if $win_lb < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $win_lb < 0 12 1587 1599
197 1599 my $win_ub = $_ + $win_to;
198 1599 ▶ $win_ub = $max if $win_ub > $max;
Branch: 1 branch
BranchTrueFalseTotal
if $win_ub > $max 12 1587 1599
199 push @wintxt, join $self->{out},
200 1599 ▶ (@{$self->{contents}}[$win_lb .. $win_ub],
Branch: 1 branch
BranchTrueFalseTotal
$win_ub < $max || !$self->{'last_line_short'} ? : 1597 2 1599
Condition100%3/3
$win_ub < $max or not $self->{"last_line_short"}
l!l&&r!l&&!r
1569282
MC/DC100%2/2
$win_ub < $max or not $self->{"last_line_short"}
$win_ub < $max not $self->{"last_line_short"}
Truth table100%3/3
A or not(B)
A= $win_ub < $maxB= not $self->{"last_line_short"}
ABresult
1X1
011
000
201 1599 (($win_ub < $max) || !$self->{last_line_short}) ?
202 '' : ());
203 }
204  
205 18 map { {line => $self->{contents}[$_],
206 window => $wintxt[$_],
207 1599 ▶ ( $self->{last_line_short} && ($_ == $max)) ? ( short => 1 ) : (),
Branch: 1 branch
BranchTrueFalseTotal
$self->{'last_line_short'} && $_ == $max ? : 2 1597 1599
Condition100%3/3
$self->{"last_line_short"} and $_ == $max
!ll&&!rl&&r
159162
MC/DC100%2/2
$self->{"last_line_short"} and $_ == $max
$self->{"last_line_short"} $_ == $max
Truth table100%3/3
A and B
A= $self->{"last_line_short"}B= $_ == $max
ABresult
0X0
100
111
208 } }
209 (0..$max);
210 }
211  
212 sub diff {
213 1 ▶ my $self = shift;
Subroutine diff: called CC=1 SCAR=0.0
Pod documented
214  
215 1 $self->delta(@_)->diff;
216 }
217  
218 sub patch {
219 6 ▶ my $self = shift;
Subroutine patch: called CC=8 SCAR=20.8
Pod documented
220 6 my $patch = shift;
221 6 ▶ $patch = VCS::Lite::Delta->new($patch,@_)
Branch: 1 branch
BranchTrueFalseTotal
unless ref $patch eq "VCS::Lite::Delta" 0 6 6
222 unless ref $patch eq 'VCS::Lite::Delta';
223 6 my @out = @{$self->{contents}};
224 6 my $id = $self->id;
225 6 my $pkg = ref $self;
226 6 my @pat = $patch->hunks;
227  
228 6 for (@pat) {
229 20 for (@$_) {
230 148 my ($ind,$lin,$txt) = @$_;
231 148 ▶ next unless $ind =~ /^-/;
Branch: 1 branch
BranchTrueFalseTotal
unless $ind =~ /^-/ 66 82 148
232 82 ▶ _error($lin,'Patch failed'),return undef
Branch: 1 branch
BranchTrueFalseTotal
if $out[$lin] ne $txt 0 82 82
233 if $out[$lin] ne $txt;
234 }
235 }
236  
237 6 my $line_offset = 0;
238 6 my $lls = 0;
239
240 6 for (@pat) {
241 20 my @txt1 = grep {$_->[0] =~ /^\-/} @$_;
242 20 my @txt2 = grep {$_->[0] =~ /^\+/} @$_;
243 20 ▶ my $base_line = @txt2 ? $txt2[0][1] : $txt1[0][1] + $line_offset;
Branch: 1 branch
BranchTrueFalseTotal
@txt2 ? : 18 2 20
244 20 splice @out,$base_line,scalar(@txt1),map {$_->[2]} @txt2;
245 20 $line_offset += @txt2 - @txt1;
246 20 $lls += grep {$_->[0] eq '+/'} @txt2;
247 }
248  
249 $pkg->new($id,{
250 in => $self->{separator},
251 chomp => $self->{chomp},
252 out => $self->{out},
253 6 last_line_short => $lls,
254 },\@out);
255 }
256  
257 # Equality of two array references (contents)
258
259 sub _equal {
260 0 ▶ my ($a,$b) = @_;
Subroutine _equal: not called CC=4 SCAR=30.0
261
262 0 ▶ return 0 if @$a != @$b;
Branch: 1 branch
BranchTrueFalseTotal
if @$a != @$b 0 0 0
263
264 0 foreach (0..$#$a) {
265 0 ▶ return 0 if $a->[$_] ne $b->[$_];
Branch: 1 branch
BranchTrueFalseTotal
if $a->[$_] ne $b->[$_] 0 0 0
266 }
267
268 0 1;
269 }
270  
271 sub merge {
272 8 ▶ my ($self,$d1,$d2) = @_;
Subroutine merge: called CC=30 SCAR=36.2
Pod documented
273 8 my $pkg = ref $self;
274  
275 8 my $orig = [$self->text];
276 8 my $chg1 = [$d1->text];
277 8 my $chg2 = [$d2->text];
278 8 my $out_title = $d1->{id} . '|' . $d2->{id};
279 8 my %ins1;
280 8 my $del1 = '';
281  
282 traverse_sequences( $self->{contents}, $chg1, {
283 784 ▶ MATCH => sub { $del1 .= ' ' },
Subroutine __ANON__: called CC=1 SCAR=0.0
284 24 ▶ DISCARD_A => sub { $del1 .= '-' },
Subroutine __ANON__: called CC=1 SCAR=0.0
285 12 ▶ DISCARD_B => sub { push @{$ins1{$_[0]}},$chg1->[$_[1]] },
Subroutine __ANON__: called CC=1 SCAR=0.0
286 8 } );
287  
288 8 my %ins2;
289 8 my $del2 = '';
290  
291 traverse_sequences( $self->{contents}, $chg2, {
292 749 ▶ MATCH => sub { $del2 .= ' ' },
Subroutine __ANON__: called CC=1 SCAR=0.0
293 59 ▶ DISCARD_A => sub { $del2 .= '-' },
Subroutine __ANON__: called CC=1 SCAR=0.0
294 66 ▶ DISCARD_B => sub { push @{$ins2{$_[0]}},$chg2->[$_[1]] },
Subroutine __ANON__: called CC=1 SCAR=0.0
295 8 } );
296  
297 # First pass conflict detection: deletion on file 1 and insertion on file 2
298  
299 8 $del1 =~ s(\-+){
300 9 my $stlin = length $`;
301 9 my $numdel = length $&;
302  
303 9 ▶ my @confl = map {exists $ins2{$_} ? ($_) : ()}
Branch: 1 branch
BranchTrueFalseTotal
exists $ins2{$_} ? : 2 13 15
304 ($stlin+1..$stlin+$numdel-1);
305 9 ▶ @confl ? '*' x $numdel : $&;
Branch: 1 branch
BranchTrueFalseTotal
@confl ? : 2 7 9
306 }eg;
307  
308 # Now the other way round: deletion on file 2 and insertion on file 1
309  
310 8 $del2 =~ s(\-+){
311 38 my $stlin = length $`;
312 38 my $numdel = length $&;
313  
314 38 ▶ my @confl = map {exists $ins1{$_} ? ($_) : ()}
Branch: 1 branch
BranchTrueFalseTotal
exists $ins1{$_} ? : 0 21 21
315 ($stlin+1..$stlin+$numdel-1);
316 38 ▶ @confl ? '*' x $numdel : $&;
Branch: 1 branch
BranchTrueFalseTotal
@confl ? : 0 38 38
317 }eg;
318  
319 # Conflict type 1 is insert of 2 into deleted 1, Conflict type 2 is insert of 1 into deleted 2
320 # @defer is used to hold the 'other half' alternative for the conflict
321  
322 8 my $conflict = 0;
323 8 my $conflict_type = 0;
324 8 my @defer;
325  
326 my @out;
327  
328 8 for (0..@{$self->{contents}}) {
329  
330 # Get details pertaining to current @f0 input line
331 816 my $line = $self->{contents}[$_];
332 816 my $d1 = substr $del1,$_,1;
333 816 ▶ my $ins1 = $ins1{$_} if exists $ins1{$_};
Branch: 1 branch
BranchTrueFalseTotal
if exists $ins1{$_} 9 807 816
334 816 my $d2 = substr $del2,$_,1;
335 816 ▶ my $ins2 = $ins2{$_} if exists $ins2{$_};
Branch: 1 branch
BranchTrueFalseTotal
if exists $ins2{$_} 48 768 816
336  
337 # Insert/insert conflict. This is not a conflict if both inserts are identical.
338  
339 816 ▶ if ($ins1 && $ins2 && !&_equal($ins1,$ins2)) {
Branch: 2 branches
BranchTrueFalseTotal
if ($ins1 and $ins2 and not &_equal($ins1, $ins2)) { } 0 816 816
elsif (not $conflict_type) { } 809 7 816
Condition50%3/6
$ins1 and $ins2 and not &_equal($ins1, $ins2)
!ll&&!rl&&r
81600
$ins1 and $ins2
!ll&&!rl&&r
80790
MC/DC0%0/3
$ins1 and $ins2 and not &_equal($ins1, $ins2)
$ins1 $ins2 not &_equal($ins1, $ins2)
Truth table50%2/4
A and B and not(C)
A= $ins1B= $ins2C= not &_equal($ins1, $ins2)
ABCresult
0XX0
10X0
1100
1111
340 0 push @out, ('*'x20)."Start of conflict ".(++$conflict).
341 " Insert to Primary, Insert to Secondary ".('*'x60)."\n";
342  
343 0 push @out, @$ins1, ('*'x100)."\n", @$ins2;
344 0 push @out, ('*'x20)."End of conflict ".$conflict.('*'x80)."\n";
345 } elsif (!$conflict_type) { #Insert/Delete conflict
346  
347 # Normal insertion - may be from $ins1 or $ins2. Apply the inser and junk both $ins1 and $ins2
348  
349 809 ▶ $ins1 ||= $ins2;
Condition100%3/3
$ins1 ||= $ins2
l!l&&r!l&&!r
846755
MC/DC100%2/2
$ins1 ||= $ins2
$ins1 $ins2
Truth table100%3/3
A ||= B
A= $ins1B= $ins2
ABresult
1X1
011
000
350  
351 809 ▶ push @out, @$ins1 if defined $ins1;
Branch: 1 branch
BranchTrueFalseTotal
if defined $ins1 54 755 809
352  
353 809 undef $ins1;
354 809 undef $ins2;
355 }
356  
357 # Detect start of conflict 1 and 2
358  
359 816 ▶ if (!$conflict_type && $d1 eq '*') {
Branch: 1 branch
BranchTrueFalseTotal
if (not $conflict_type and $d1 eq "*") 2 814 816
Condition100%3/3
not $conflict_type and $d1 eq "*"
!ll&&!rl&&r
78072
MC/DC100%2/2
not $conflict_type and $d1 eq "*"
not $conflict_type $d1 eq "*"
Truth table100%3/3
not(A) and B
A= not $conflict_typeB= $d1 eq "*"
ABresult
0X0
100
111
360 2 push @out, ('*'x20)."Start of conflict ".(++$conflict).
361 " Delete from Primary, Insert to Secondary ".('*'x60)."\n";
362  
363 2 $conflict_type = 1;
364 }
365  
366 816 ▶ if (!$conflict_type && $d2 eq '*') {
Branch: 1 branch
BranchTrueFalseTotal
if (not $conflict_type and $d2 eq "*") 0 816 816
Condition66%2/3
not $conflict_type and $d2 eq "*"
!ll&&!rl&&r
98070
MC/DC0%0/2
not $conflict_type and $d2 eq "*"
not $conflict_type $d2 eq "*"
Truth table66%2/3
not(A) and B
A= not $conflict_typeB= $d2 eq "*"
ABresult
0X0
100
111
367 0 push @out, ('*'x20)."Start of conflict ".(++$conflict).
368 " Delete from Secondary, Insert to Primary ".('*'x60)."\n";
369  
370 0 $conflict_type = 2;
371 }
372  
373 # Handle case where we are in an Insert/Delete conflict block already
374  
375 816 ▶ if ($conflict_type == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($conflict_type == 1) 9 807 816
376 9 ▶ if ($d1 eq '*') {
Branch: 1 branch
BranchTrueFalseTotal
if ($d1 eq '*') { } 7 2 9
377  
378 # Deletion block continues...
379 7 ▶ push @defer,(@$ins2) if $ins2;
Branch: 1 branch
BranchTrueFalseTotal
if $ins2 2 5 7
380 7 ▶ push @defer,$line if !$d2;
Branch: 1 branch
BranchTrueFalseTotal
unless $d2 0 7 7
381 } else {
382  
383 # handle end of block, dump out @defer and clear it
384  
385 2 push @out, ('*'x100)."\n",@defer;
386 2 undef @defer;
387 2 push @out, ('*'x20)."End of conflict ".$conflict.('*'x80)."\n";
388 2 $conflict_type = 0;
389 }
390 }
391  
392 816 ▶ if ($conflict_type == 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($conflict_type == 2) 0 816 816
393 0 ▶ if ($d2 eq '*') {
Branch: 1 branch
BranchTrueFalseTotal
if ($d2 eq '*') { } 0 0 0
394  
395 # Deletion block continues...
396 0 ▶ push @defer,(@$ins1) if $ins1;
Branch: 1 branch
BranchTrueFalseTotal
if $ins1 0 0 0
397 0 ▶ push @defer,$line if !$d1;
Branch: 1 branch
BranchTrueFalseTotal
unless $d1 0 0 0
398 } else {
399  
400 # handle end of block, dump out @defer and clear it
401  
402 0 push @out, ('*'x100),"\n", @defer;
403 0 undef @defer;
404 0 push @out, ('*'x20)."End of conflict ".$conflict.('*'x80)."\n";
405 0 $conflict_type = 0;
406 }
407 }
408 816 ▶ last unless defined $line; # for end of file, don't want to push undef
Branch: 1 branch
BranchTrueFalseTotal
unless defined $line 8 808 816
409 808 ▶ push @out, $line unless ($d1 eq '-' || $d2 eq '-') && !$conflict_type;
Branch: 1 branch
BranchTrueFalseTotal
unless $d1 eq "-" || $d2 eq "-" and not $conflict_type 735 73 808
Condition100%6/6
$d1 eq "-" || $d2 eq "-" and not $conflict_type
!ll&&!rl&&r
732373
$d1 eq "-" or $d2 eq "-"
l!l&&r!l&&!r
1759732
MC/DC100%3/3
$d1 eq "-" || $d2 eq "-" and not $conflict_type
$d1 eq "-" $d2 eq "-" not $conflict_type
Truth table80%4/5
A or B and not(C)
A= $d1 eq "-"B= $d2 eq "-"C= not $conflict_type
ABCresult
00X0
1X00
0100
1X11
0111
410 }
411 8 $pkg->new($out_title, undef, \@out);
412 }
413  
414 ▶sub _error {};
Subroutine _error: not called CC=1 SCAR=0.0
415  
416 9 1;
417  
418 __END__
« Lite/Delta.pm ↑ Summary