| 1 | package Text::Diff3::DiffHeckel; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # two-way diff plug-in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 6 | ▶ | use 5.006; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 6 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 6 | ▶ | use base qw(Text::Diff3::Base); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 6 | ▶ | use version; our $VERSION = '0.08'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 48 | ▶ | sub diff { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
diff: called CC=23 SCAR=31.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 48 | my($self, $A, $B) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 48 | my $f = $self->factory; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 48 | ▶ | if (! $self->_is_a_text($A)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 0 | $A = $f->create_text($A); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 48 | ▶ | if (! $self->_is_a_text($B)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 0 | $B = $f->create_text($B); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 48 | my $diff = $f->create_list2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 48 | my @uniq = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | [$A->first_index - 1, $B->first_index - 1], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | [$A->last_index + 1, $B->last_index + 1] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 48 | my(%freq, %ap, %bp); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 48 | for my $lineno ($A->range) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 289 | my $s = $A->at($lineno); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 289 | $freq{$s} += 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 289 | $ap{$s} = $lineno; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 48 | for my $lineno ($B->range) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 301 | my $s = $B->at($lineno); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 301 | $freq{$s} += 3; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 301 | $bp{$s} = $lineno; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 48 | ▶ | while (my($s, $x) = each %freq) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 354 | ▶ | next if $x != 5; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 225 | push @uniq, [$ap{$s}, $bp{$s}]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 48 | @uniq = sort { $a->[0] <=> $b->[0] } @uniq; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 48 | my($AL, $BL) = ($A->last_index, $B->last_index); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 48 | my($a1, $b1) = ($A->first_index, $B->first_index); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 48 | ▶ | while ($a1 <= $AL && $b1 <= $BL && $A->eq_at($a1, $B->at($b1))) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$a1 <= $AL and $b1 <= $BL and $A->eq_at($a1, $B->at($b1))
$a1 <= $AL and $b1 <= $BL
MC/DC100%3/3
$a1 <= $AL and $b1 <= $BL and $A->eq_at($a1, $B->at($b1))
$a1 <= $AL
$b1 <= $BL
$A->eq_at($a1, $B->at($b1))
Truth table100%4/4
A and B and C
A= $a1 <= $ALB= $b1 <= $BLC= $A->eq_at($a1, $B->at($b1))
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 138 | $a1++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 138 | $b1++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 48 | my($a0, $b0) = ($a1, $b1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 48 | for (@uniq) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 321 | my($auniq, $buniq) = @{$_}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 321 | ▶ | next if $auniq < $a0 || $buniq < $b0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$auniq < $a0 or $buniq < $b0
MC/DC50%1/2
$auniq < $a0 or $buniq < $b0
$auniq < $a0
$buniq < $b0
Truth table66%2/3
A or B
A= $auniq < $a0B= $buniq < $b0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 90 | ($a1, $b1) = ($auniq - 1, $buniq - 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 90 | ▶ | while ($a0 <= $a1 && $b0 <= $b1 && $A->eq_at($a1, $B->at($b1))) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$a0 <= $a1 and $b0 <= $b1 and $A->eq_at($a1, $B->at($b1))
$a0 <= $a1 and $b0 <= $b1
MC/DC0%0/3
$a0 <= $a1 and $b0 <= $b1 and $A->eq_at($a1, $B->at($b1))
$a0 <= $a1
$b0 <= $b1
$A->eq_at($a1, $B->at($b1))
Truth table75%3/4
A and B and C
A= $a0 <= $a1B= $b0 <= $b1C= $A->eq_at($a1, $B->at($b1))
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | $a1--; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | $b1--; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 90 | ▶ | if ($a0 <= $a1 && $b0 <= $b1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition100%3/3
$a0 <= $a1 and $b0 <= $b1
MC/DC100%2/2
$a0 <= $a1 and $b0 <= $b1
$a0 <= $a1
$b0 <= $b1
Truth table100%3/3
A and B
A= $a0 <= $a1B= $b0 <= $b1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 16 | $diff->push($f->create_range2('c', $a0, $a1, $b0, $b1)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | } elsif ($a0 <= $a1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 15 | $diff->push($f->create_range2('d', $a0, $a1, $b0, $b0 - 1)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | } elsif ($b0 <= $b1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 20 | $diff->push($f->create_range2('a', $a0, $a0 - 1, $b0, $b1)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 90 | ($a1, $b1) = ($auniq + 1, $buniq + 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 90 | ▶ | while ($a1 <= $AL && $b1 <= $BL && $A->eq_at($a1, $B->at($b1))) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$a1 <= $AL and $b1 <= $BL and $A->eq_at($a1, $B->at($b1))
$a1 <= $AL and $b1 <= $BL
MC/DC66%2/3
$a1 <= $AL and $b1 <= $BL and $A->eq_at($a1, $B->at($b1))
$a1 <= $AL
$b1 <= $BL
$A->eq_at($a1, $B->at($b1))
Truth table75%3/4
A and B and C
A= $a1 <= $ALB= $b1 <= $BLC= $A->eq_at($a1, $B->at($b1))
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 45 | $a1++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 45 | $b1++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 90 | ($a0, $b0) = ($a1, $b1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 48 | return $diff; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 96 | ▶ | sub _is_a_text { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_is_a_text: called CC=5 SCAR=19.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 96 | my($self, $x) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 96 | return eval{ $x->can('first_index') } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 96 | && eval{ $x->can('last_index') } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 96 | && eval{ $x->can('range') } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 96 | && eval{ $x->can('at') } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 96 | ▶ | && eval{ $x->can('eq_at') }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%4/12
eval {
do {
$x->can('first_index')
}
} && eval {
do {
$x->can('last_index')
}
} && eval {
do {
$x->can('range')
}
} && eval {
do {
$x->can('at')
}
} && eval {
do {
$x->can('eq_at')
}
}
eval {
do {
$x->can("first_index")
}
} and eval {
do {
$x->can("last_index")
}
} and eval {
do {
$x->can("range")
}
} and eval {
do {
$x->can("at")
}
}
eval {
do {
$x->can("first_index")
}
} and eval {
do {
$x->can("last_index")
}
} and eval {
do {
$x->can("range")
}
}
eval {
do {
$x->can("first_index")
}
} and eval {
do {
$x->can("last_index")
}
}
MC/DC0%0/5
eval {
do {
$x->can('first_index')
}
} && eval {
do {
$x->can('last_index')
}
} && eval {
do {
$x->can('range')
}
} && eval {
do {
$x->can('at')
}
} && eval {
do {
$x->can('eq_at')
}
}
eval {
do {
$x->can("first_index")
}
}
eval {
do {
$x->can("last_index")
}
}
eval {
do {
$x->can("range")
}
}
eval {
do {
$x->can("at")
}
}
eval {
do {
$x->can('eq_at')
}
}
Truth table16%1/6
A and B and C and D && E
A= eval {
do {
$x->can("first_index")
}
}B= eval {
do {
$x->can("last_index")
}
}C= eval {
do {
$x->can("range")
}
}D= eval {
do {
$x->can("at")
}
}E= eval {
do {
$x->can('eq_at')
}
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 6 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||