Diff3/Text.pm

filter: Statementstmt 75.4% 40 / 53 Branchbran 58.3% 7 / 12 Conditioncond 83.3% 5 / 6 MC/DCmcdc 75.0% 3 / 4 Subroutinesub 80.0% 12 / 15 Podpod 100% 10 / 10 totaltotal 77.0% 77 / 100 CC 10 SCAR 12.8
CC
10
Cov
73%
as_string_range
12.0
as_string_at
6.0
initialize
3.1
CRAP 3.6
« Diff3/Diff3.pm ↑ Summary Diff3/ListMixin.pm »
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
BranchTrueFalseTotal
$x < 0 || $x > $#{$$self{'text'};} ? : 4 1115 1119
Condition66%2/3
$x < 0 or $x > $#{$$self{"text"};}
l!l&&r!l&&!r
401115
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"};}
ABresult
1X1
011
000
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
BranchTrueFalseTotal
if (defined $line) 0 0 0
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
BranchTrueFalseTotal
defined $line ? : 0 0 0
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
BranchTrueFalseTotal
if defined $this ^ defined $other 2 260 262
52 260 ▶ return ! (defined $this) || $this eq $other;
Condition100%3/3
!defined($this) || $this eq $other
l!l&&r!l&&!r
119960
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
ABresult
1X1
011
000
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
BranchTrueFalseTotal
if (ref $s eq 'ARRAY') { } 76 1 77
60 76 $self->{text} = $s;
61 } else {
62 1 ▶ if (ref $s) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $s) 0 1 1
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__
« Diff3/Diff3.pm ↑ Summary Diff3/ListMixin.pm »