| 1 | package Text::Diff3::Text; | ||||||||||||||||||||||||||||
| 2 | 6 | ▶ | use 5.006; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 6 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 6 | ▶ | use base qw(Text::Diff3::ListMixin Text::Diff3::Base); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 6 | ▶ | use version; our $VERSION = '0.08'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 0 | ▶ | sub text { return $_[0]->{text} } | ||||||||||||||||||||||||||
|
Subroutine
text: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | sub list { return $_[0]->{text} } # interface to ListMixin | ||||||||||||||||||||||||||
|
Subroutine
list: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 1704 | ▶ | sub first_index { return 1 } | ||||||||||||||||||||||||||
|
Subroutine
first_index: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 291 | ▶ | sub last_index { | ||||||||||||||||||||||||||
|
Subroutine
last_index: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 15 | 291 | my($self) = @_; | |||||||||||||||||||||||||||
| 16 | 291 | return $#{$self->{text}} + $self->first_index; | |||||||||||||||||||||||||||
| 17 | } | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 97 | ▶ | sub range { | ||||||||||||||||||||||||||
|
Subroutine
range: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 20 | 97 | my($self) = @_; | |||||||||||||||||||||||||||
| 21 | 97 | return ($self->first_index .. $self->last_index); | |||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 1119 | ▶ | sub at { | ||||||||||||||||||||||||||
|
Subroutine
at: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 25 | 1119 | my($self, $x) = @_; | |||||||||||||||||||||||||||
| 26 | 1119 | $x -= $self->first_index; | |||||||||||||||||||||||||||
| 27 | 1119 | ▶ | return $x < 0 || $x > $#{$self->{text}} ? undef : $self->{text}[$x]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$x < 0 or $x > $#{$$self{"text"};}
MC/DC50%1/2
$x < 0 or $x > $#{$$self{"text"};}
$x < 0
$x > $#{$$self{"text"};}
Truth table66%2/3
A or B
A= $x < 0B= $x > $#{$$self{"text"};}
| |||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 0 | ▶ | sub as_string_range { | ||||||||||||||||||||||||||
|
Subroutine
as_string_range: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 31 | 0 | my($self, @range) = @_; | |||||||||||||||||||||||||||
| 32 | 0 | my $t = q{}; | |||||||||||||||||||||||||||
| 33 | 0 | for (@range) { | |||||||||||||||||||||||||||
| 34 | 0 | my $line = $self->at($_); | |||||||||||||||||||||||||||
| 35 | 0 | ▶ | if (defined $line) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 36 | 0 | $t .= $line . "\n"; | |||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | 0 | return $t; | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 0 | ▶ | sub as_string_at { | ||||||||||||||||||||||||||
|
Subroutine
as_string_at: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 43 | 0 | my($self, $x) = @_; | |||||||||||||||||||||||||||
| 44 | 0 | my $line = $self->at($x); | |||||||||||||||||||||||||||
| 45 | 0 | ▶ | return defined($line) ? $line . "\n" : q{}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 262 | ▶ | sub eq_at { | ||||||||||||||||||||||||||
|
Subroutine
eq_at: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 49 | 262 | my($self, $x, $other) = @_; | |||||||||||||||||||||||||||
| 50 | 262 | my $this = $self->at($x); | |||||||||||||||||||||||||||
| 51 | 262 | ▶ | return 0 if (defined $this) ^ (defined $other); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 52 | 260 | ▶ | return ! (defined $this) || $this eq $other; | ||||||||||||||||||||||||||
|
Condition100%3/3
!defined($this) || $this eq $other
MC/DC100%2/2
!defined($this) || $this eq $other
!defined($this)
$this eq $other
Truth table100%3/3
not(A) || B
A= !defined($this)B= $this eq $other
| |||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 77 | ▶ | sub initialize { | ||||||||||||||||||||||||||
|
Subroutine
initialize: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||||||||||||||||||
| 56 | 77 | my($self, @arg) = @_; | |||||||||||||||||||||||||||
| 57 | 77 | $self->SUPER::initialize(@arg); | |||||||||||||||||||||||||||
| 58 | 77 | my($f, $s) = @arg; | |||||||||||||||||||||||||||
| 59 | 77 | ▶ | if (ref $s eq 'ARRAY') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 60 | 76 | $self->{text} = $s; | |||||||||||||||||||||||||||
| 61 | } else { | ||||||||||||||||||||||||||||
| 62 | 1 | ▶ | if (ref $s) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 63 | 0 | $s = ${$s}; | |||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | 1 | chomp $s; | |||||||||||||||||||||||||||
| 66 | 1 | $self->{text} = [split /\n/msx, $s, -1]; | |||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | 77 | return $self; | |||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 6 | 1; | |||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | __END__ | ||||||||||||||||||||||||||||