blib/lib/Tag/Reader/Perl.pm

filter: Statementstmt 94.4% 171 / 181 Branchbran 85.1% 80 / 94 Conditioncond 79.4% 81 / 102 MC/DCmcdc 46.3% 25 / 54 Subroutinesub 100% 14 / 14 Podpod 100% 4 / 4 totaltotal 83.5% 375 / 449 CC 82 SCAR 34.8
CC
82
Cov
88%
_gettoken
52.9
set_file
11.8
gettoken
11.3
CRAP 32.3
↑ Summary
1 package Tag::Reader::Perl;
2  
3 # Pragmas.
4 14 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 14 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 # Modules.
8 14 ▶use Class::Utils qw(set_params);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 14 ▶use Error::Pure qw(err);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 14 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 # Constants.
13 14 Readonly::Scalar my $EMPTY_STR => q{};
14  
15 # Version.
16 14 our $VERSION = '0.01';
17  
18 # Constructor.
19 sub new {
20 55 ▶ my ($class, @params) = @_;
Subroutine new: called CC=1 SCAR=0.0
Pod documented
21 55 my $self = bless {}, $class;
22  
23 # Process params.
24 55 set_params($self, @params);
25  
26 # Object.
27 53 return $self;
28 }
29  
30 # Get tag token.
31 sub gettoken {
32 170 ▶ my $self = shift;
Subroutine gettoken: called CC=11 SCAR=24.2
Pod documented
33  
34 # Stay.
35 170 $self->{'stay'} = 0;
36 170 $self->{'spec_stay'} = 0;
37 170 $self->{'old_stay'} = 0;
38  
39 # Data.
40 170 $self->{'data'} = [];
41  
42 # Tag type.
43 170 $self->{'tag_type'} = '!data';
44 170 $self->{'tag_length'} = 0;
45  
46 # Braces.
47 170 ($self->{'brace'}, $self->{'bracket'}) = (0, 0);
48  
49 # Quote.
50 170 $self->{'quote'} = $EMPTY_STR;
51  
52 # Tag line.
53 170 $self->{'tagline'} = $self->{'textline'};
54 170 $self->{'tagcharpos'} = 0;
55  
56 170 ▶ if (exists $self->{'text'}) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $self->{'text'}) { } 32 138 170
elsif (exists $self->{'filename'}) { } 138 0 138
57 32 ▶ while (exists $self->{'text'}
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"text"} and $self->{"stay"} < 98 and defined($self->{"char"} = substr($self->{"text"}, 0, 1))) 705 32 737
Condition66%4/6
exists $self->{"text"} and $self->{"stay"} < 98 and defined($self->{"char"} = substr($self->{"text"}, 0, 1))
!ll&&!rl&&r
320705
exists $self->{"text"} and $self->{"stay"} < 98
!ll&&!rl&&r
032705
MC/DC33%1/3
exists $self->{"text"} and $self->{"stay"} < 98 and defined($self->{"char"} = substr($self->{"text"}, 0, 1))
exists $self->{"text"} $self->{"stay"} < 98 defined($self->{"char"} = substr($self->{"text"}, 0, 1))
Truth table50%2/4
A and B and C
A= exists $self->{"text"}B= $self->{"stay"} < 98C= defined($self->{"char"} = substr($self->{"text"}, 0, 1))
ABCresult
0XX0
10X0
1100
1111
58 && $self->{'stay'} < 98
59 && defined ($self->{'char'}
60 = substr $self->{'text'}, 0, 1)) {
61  
62 705 $self->_gettoken;
63 }
64 } elsif (exists $self->{'filename'}) {
65 138 ▶ while ($self->{'stay'} < 98
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"stay"} < 98 and defined($self->{"char"} = shift @{$$self{"old_data"};}) || defined($self->{"char"} = getc $self->{"filename"})) 3764 138 3902
Condition100%6/6
$self->{"stay"} < 98 and defined($self->{"char"} = shift @{$$self{"old_data"};}) || defined($self->{"char"} = getc $self->{"filename"})
!ll&&!rl&&r
13443764
defined($self->{"char"} = shift @{$$self{"old_data"};}) or defined($self->{"char"} = getc $self->{"filename"})
l!l&&r!l&&!r
3937254
MC/DC66%2/3
$self->{"stay"} < 98 and defined($self->{"char"} = shift @{$$self{"old_data"};}) || defined($self->{"char"} = getc $self->{"filename"})
$self->{"stay"} < 98 defined($self->{"char"} = shift @{$$self{"old_data"};}) defined($self->{"char"} = getc $self->{"filename"})
Truth table75%3/4
A and B or C
A= $self->{"stay"} < 98B= defined($self->{"char"} = shift @{$$self{"old_data"};})C= defined($self->{"char"} = getc $self->{"filename"})
ABCresult
0XX0
1000
11X1
1011
66 && ((defined ($self->{'char'}
67 3768 = shift @{$self->{'old_data'}}))
68 || defined ($self->{'char'}
69 = getc $self->{'filename'}))) {
70  
71 3764 $self->_gettoken;
72 }
73 }
74  
75 170 my $data = join $EMPTY_STR, @{$self->{'data'}};
76 170 ▶ if ($data eq $EMPTY_STR) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data eq $EMPTY_STR) 0 170 170
77 0 return ();
78 }
79 return wantarray ? ($data, $self->{'tag_type'}, $self->{'tagline'},
80 170 ▶ $self->{'tagcharpos'}) : $data;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 170 0 170
81 }
82  
83 # Set file.
84 sub set_file {
85 52 ▶ my ($self, $file, $force) = @_;
Subroutine set_file: called CC=7 SCAR=24.7
Pod documented
86 52 ▶ if (! $file || ! -r $file) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($file and -r $file) 0 52 52
Condition33%1/3
$file and -r $file
!ll&&!rl&&r
0052
MC/DC0%0/2
$file and -r $file
$file -r $file
Truth table33%1/3
A and B
A= $fileB= -r $file
ABresult
0X0
100
111
87 0 err 'Bad file.';
88 }
89 52 ▶ if (! $force && (defined $self->{'text'}
Branch: 1 branch
BranchTrueFalseTotal
if (not $force and defined $self->{"text"} || defined $self->{"filename"}) 0 52 52
Condition33%2/6
not $force and defined $self->{"text"} || defined $self->{"filename"}
!ll&&!rl&&r
0520
defined $self->{"text"} or defined $self->{"filename"}
l!l&&r!l&&!r
0052
MC/DC0%0/3
not $force and defined $self->{"text"} || defined $self->{"filename"}
not $force defined $self->{"text"} defined $self->{"filename"}
Truth table25%1/4
not(A) and B or C
A= not $forceB= defined $self->{"text"}C= defined $self->{"filename"}
ABCresult
0XX0
1000
11X1
1011
90 || defined $self->{'filename'})) {
91  
92 0 err 'Cannot set new data if exists data.';
93 }
94 52 my $inf;
95 52 ▶ if (! open $inf, '<', $file) {
Branch: 1 branch
BranchTrueFalseTotal
unless (open $inf, "<", $file) 0 52 52
96 0 err "Cannot open file '$file'.";
97 }
98 52 $self->{'filename'} = $inf;
99  
100 # Reset values.
101 52 $self->_reset;
102  
103 52 return;
104 }
105  
106 # Set text.
107 sub set_text {
108 3 ▶ my ($self, $text, $force) = @_;
Subroutine set_text: called CC=5 SCAR=20.9
Pod documented
109 3 ▶ if (! $text) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($text) 0 3 3
110 0 err 'Bad text.';
111 }
112 3 ▶ if (! $force && (defined $self->{'text'}
Branch: 1 branch
BranchTrueFalseTotal
if (not $force and defined $self->{"text"} || defined $self->{"filename"}) 0 3 3
Condition16%1/6
not $force and defined $self->{"text"} || defined $self->{"filename"}
!ll&&!rl&&r
300
defined $self->{"text"} or defined $self->{"filename"}
l!l&&r!l&&!r
000
MC/DC0%0/3
not $force and defined $self->{"text"} || defined $self->{"filename"}
not $force defined $self->{"text"} defined $self->{"filename"}
Truth table25%1/4
not(A) and B or C
A= not $forceB= defined $self->{"text"}C= defined $self->{"filename"}
ABCresult
0XX0
1000
11X1
1011
113 || defined $self->{'filename'})) {
114  
115 0 err 'Cannot set new data if exists data.';
116 }
117 3 $self->{'text'} = $text;
118  
119 # Reset values.
120 3 $self->_reset;
121  
122 3 return;
123 }
124  
125 # Reset class values.
126 sub _reset {
127 55 ▶ my $self = shift;
Subroutine _reset: called CC=1 SCAR=0.0
128  
129 # Default values.
130 55 $self->{'charpos'} = 0;
131 55 $self->{'tagcharpos'} = 0;
132 55 $self->{'textline'} = 1;
133 55 $self->{'tagline'} = 0;
134 55 $self->{'old_data'} = [];
135  
136 55 return;
137 }
138  
139 # Main get token.
140 sub _gettoken {
141 4469 ▶ my $self = shift;
Subroutine _gettoken: called CC=52 SCAR=39.7
142  
143 # Char position.
144 4469 $self->{'charpos'}++;
145  
146 # Normal tag.
147 4469 ▶ if ($self->{'spec_stay'} == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'spec_stay'} == 0) { } 1092 3377 4469
148  
149 # Begin of normal tag.
150 1092 ▶ if ($self->{'stay'} == 0 && $self->{'char'} eq '<') {
Branch: 3 branches
BranchTrueFalseTotal
if ($self->{'stay'} == 0 and $self->{'char'} eq '<') { } 166 926 1092
elsif ($self->{'stay'} == 0) { } 190 736 926
elsif ($self->{'stay'} == 1) { } 736 0 736
Condition100%3/3
$self->{"stay"} == 0 and $self->{"char"} eq "<"
!ll&&!rl&&r
736190166
MC/DC100%2/2
$self->{"stay"} == 0 and $self->{"char"} eq "<"
$self->{"stay"} == 0 $self->{"char"} eq "<"
Truth table100%3/3
A and B
A= $self->{"stay"} == 0B= $self->{"char"} eq "<"
ABresult
0X0
100
111
151  
152 # In tag.
153 166 ▶ if ($#{$self->{'data'}} == -1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($#{$$self{'data'};} == -1) { } 111 55 166
154 $self->{'tagcharpos'}
155 111 = $self->{'charpos'};
156 111 $self->{'stay'} = 1;
157 111 push @{$self->{'data'}}, $self->{'char'};
158 111 $self->{'tag_length'} = 1;
159  
160 # Start of tag, after data.
161 } else {
162 55 $self->{'stay'} = 99;
163 }
164  
165 # Text.
166 } elsif ($self->{'stay'} == 0) {
167 190 push @{$self->{'data'}}, $self->{'char'};
168 190 ▶ if ($self->{'tagcharpos'} == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tagcharpos"} == 0) 59 131 190
169 $self->{'tagcharpos'}
170 59 = $self->{'charpos'};
171 }
172  
173 # In a normal tag.
174 } elsif ($self->{'stay'} == 1) {
175  
176 # End of normal tag.
177 736 ▶ if ($self->{'char'} eq '>') {
Branch: 3 branches
BranchTrueFalseTotal
if ($self->{'char'} eq '>') { } 47 689 736
elsif ($self->{'tag_length'} == 1 and _is_first_char_of_tag($self->{'char'})) { } 111 578 689
elsif ($self->{'tag_length'} > 1 and _is_in_tag_name($self->{'char'})) { } 247 331 578
178 47 $self->{'stay'} = 98;
179 47 $self->_tag_type;
180 47 push @{$self->{'data'}}, $self->{'char'};
181 47 $self->{'tag_length'} = 0;
182  
183 # First charcter after '<' in normal tag.
184 ▶ } elsif ($self->{'tag_length'} == 1
Condition66%2/3
$self->{"tag_length"} == 1 and _is_first_char_of_tag($self->{"char"})
!ll&&!rl&&r
5780111
MC/DC50%1/2
$self->{"tag_length"} == 1 and _is_first_char_of_tag($self->{"char"})
$self->{"tag_length"} == 1 _is_first_char_of_tag($self->{"char"})
Truth table66%2/3
A and B
A= $self->{"tag_length"} == 1B= _is_first_char_of_tag($self->{"char"})
ABresult
0X0
100
111
185 && _is_first_char_of_tag($self->{'char'})) {
186  
187 111 ▶ if ($self->{'char'} eq q{!}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"char"} eq "!") 64 47 111
188 64 $self->{'spec_stay'} = 1;
189 }
190 111 push @{$self->{'data'}}, $self->{'char'};
191 111 $self->{'tag_length'}++;
192  
193 # Next character in normal tag (name).
194 ▶ } elsif ($self->{'tag_length'} > 1
Condition100%3/3
$self->{"tag_length"} > 1 and _is_in_tag_name($self->{"char"})
!ll&&!rl&&r
31615247
MC/DC100%2/2
$self->{"tag_length"} > 1 and _is_in_tag_name($self->{"char"})
$self->{"tag_length"} > 1 _is_in_tag_name($self->{"char"})
Truth table100%3/3
A and B
A= $self->{"tag_length"} > 1B= _is_in_tag_name($self->{"char"})
ABresult
0X0
100
111
195 && _is_in_tag_name($self->{'char'})) {
196  
197 247 push @{$self->{'data'}}, $self->{'char'};
198 247 $self->{'tag_length'}++;
199  
200 # Other characters.
201 } else {
202 331 ▶ if ($self->{'tag_length'} == 1
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tag_length"} == 1 or $self->{"char"} eq "<") 0 331 331
Condition33%1/3
$self->{"tag_length"} == 1 or $self->{"char"} eq "<"
l!l&&r!l&&!r
00331
MC/DC0%0/2
$self->{"tag_length"} == 1 or $self->{"char"} eq "<"
$self->{"tag_length"} == 1 $self->{"char"} eq "<"
Truth table33%1/3
A or B
A= $self->{"tag_length"} == 1B= $self->{"char"} eq "<"
ABresult
1X1
011
000
203 || $self->{'char'} eq '<') {
204  
205 0 err 'Bad tag.';
206 }
207 331 $self->_tag_type;
208 331 push @{$self->{'data'}}, $self->{'char'};
209 }
210 }
211  
212 # Other tags.
213 } else {
214  
215 # End of normal tag.
216 3377 ▶ if ($self->{'char'} eq '>') {
Branch: 5 branches
BranchTrueFalseTotal
if ($self->{'char'} eq '>') { } 90 3287 3377
elsif ($self->{'spec_stay'} == 3) { } 56 3231 3287
elsif ($self->{'spec_stay'} == 4) { } 812 2419 3231
elsif ($self->{'char'} eq ']') { } 13 2406 2419
elsif ($self->{'tag_length'} > 1 and _is_in_tag_name($self->{'char'})) { } 409 1997 2406
217 90 ▶ if (($self->{'brace'} == 0
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"brace"} == 0 and $self->{"bracket"} == 0 and $self->{"spec_stay"} < 3 or $self->{"spec_stay"} == 3 and join($EMPTY_STR, @{$$self{"data"};}[-2, -1]) eq "--" or $self->{"tag_type"} =~ /^!\[cdata\[/ms and join($EMPTY_STR, @{$$self{"data"};}[-2, -1]) eq "]]") 4 26 30
Condition100%15/15
$self->{"brace"} == 0 and $self->{"bracket"} == 0 and $self->{"spec_stay"} < 3 or $self->{"spec_stay"} == 3 and join($EMPTY_STR, @{$$self{"data"};}[-2, -1]) eq "--" or $self->{"tag_type"} =~ /^!\[cdata\[/ms and join($EMPTY_STR, @{$$self{"data"};}[-2, -1]) eq "]]"
l!l&&r!l&&!r
63126
$self->{"brace"} == 0 and $self->{"bracket"} == 0 and $self->{"spec_stay"} < 3 or $self->{"spec_stay"} == 3 and join($EMPTY_STR, @{$$self{"data"};}[-2, -1]) eq "--"
l!l&&r!l&&!r
60327
$self->{"brace"} == 0 and $self->{"bracket"} == 0 and $self->{"spec_stay"} < 3
!ll&&!rl&&r
26460
$self->{"brace"} == 0 and $self->{"bracket"} == 0
!ll&&!rl&&r
23364
$self->{"spec_stay"} == 3 and join($EMPTY_STR, @{$$self{"data"};}[-2, -1]) eq "--"
!ll&&!rl&&r
2433
MC/DC0%0/6
$self->{"brace"} == 0 and $self->{"bracket"} == 0 and $self->{"spec_stay"} < 3 or $self->{"spec_stay"} == 3 and join($EMPTY_STR, @{$$self{"data"};}[-2, -1]) eq "--" or $self->{"tag_type"} =~ /^!\[cdata\[/ms and join($EMPTY_STR, @{$$self{"data"};}[-2, -1]) eq "]]"
$self->{"brace"} == 0 $self->{"bracket"} == 0 $self->{"spec_stay"} < 3 $self->{"spec_stay"} == 3 join($EMPTY_STR, @{$$self{"data"};}[-2, -1]) eq "--" $self->{"tag_type"} =~ /^!\[cdata\[/ms and join($EMPTY_STR, @{$$self{"data"};}[-2, -1]) eq "]]"
Truth table25%4/16
A and B and C or D and E or F
A= $self->{"brace"} == 0B= $self->{"bracket"} == 0C= $self->{"spec_stay"} < 3D= $self->{"spec_stay"} == 3E= join($EMPTY_STR, @{$$self{"data"};}[-2, -1]) eq "--"F= $self->{"tag_type"} =~ /^!\[cdata\[/ms and join($EMPTY_STR, @{$$self{"data"};}[-2, -1]) eq "]]"
ABCDEFresult
111XXX1
0XX11X1
10X11X1
11011X1
0XX0X11
0XX1011
10X0X11
10X1011
1100X11
1101011
0XX0X00
0XX1000
10X0X00
10X1000
1100X00
1101000
218 && $self->{'bracket'} == 0
219 && $self->{'spec_stay'} < 3)
220  
221 # Comment.
222 || ($self->{'spec_stay'} == 3
223 && join($EMPTY_STR,
224 6 ▶ @{$self->{'data'}}[-2 .. -1])
Condition100%3/3
$self->{"tag_type"} =~ /^!\[cdata\[/ms and join($EMPTY_STR, @{$$self{"data"};}[-2, -1]) eq "]]"
!ll&&!rl&&r
2331
MC/DC100%2/2
$self->{"tag_type"} =~ /^!\[cdata\[/ms and join($EMPTY_STR, @{$$self{"data"};}[-2, -1]) eq "]]"
$self->{"tag_type"} =~ /^!\[cdata\[/ms join($EMPTY_STR, @{$$self{"data"};}[-2, -1]) eq "]]"
Truth table100%3/3
A and B
A= $self->{"tag_type"} =~ /^!\[cdata\[/msB= join($EMPTY_STR, @{$$self{"data"};}[-2, -1]) eq "]]"
ABresult
0X0
100
111
225 eq q{--})
226  
227 # CDATA.
228 || ($self->{'tag_type'} =~ /^!\[cdata\[/ms
229 && join($EMPTY_STR,
230 4 @{$self->{'data'}}[-2 .. -1])
231 eq ']]')) {
232  
233 64 $self->{'stay'} = 98;
234 64 $self->{'spec_stay'} = 0;
235 64 $self->{'tag_length'} = 0;
236 }
237 90 ▶ if ($self->{'spec_stay'} != 4) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"spec_stay"} != 4) 89 1 90
238 89 $self->{'bracket'}--;
239 }
240 90 push @{$self->{'data'}}, $self->{'char'};
241  
242 # Comment.
243 } elsif ($self->{'spec_stay'} == 3) {
244  
245 # '--' is bad.
246 56 ▶ if ($self->{'tag_length'} == 0
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tag_length"} == 0 and join($EMPTY_STR, @{$$self{"data"};}[-2, -1]) eq "--") 0 56 56
Condition66%2/3
$self->{"tag_length"} == 0 and join($EMPTY_STR, @{$$self{"data"};}[-2, -1]) eq "--"
!ll&&!rl&&r
3530
MC/DC0%0/2
$self->{"tag_length"} == 0 and join($EMPTY_STR, @{$$self{"data"};}[-2, -1]) eq "--"
$self->{"tag_length"} == 0 join($EMPTY_STR, @{$$self{"data"};}[-2, -1]) eq "--"
Truth table66%2/3
A and B
A= $self->{"tag_length"} == 0B= join($EMPTY_STR, @{$$self{"data"};}[-2, -1]) eq "--"
ABresult
0X0
100
111
247 53 && join($EMPTY_STR, @{$self->{'data'}}
248 [-2 .. -1]) eq q{--}) {
249  
250 0 err 'Bad tag.';
251 }
252 56 $self->_tag_type;
253 56 push @{$self->{'data'}}, $self->{'char'};
254  
255 # Quote.
256 } elsif ($self->{'spec_stay'} == 4) {
257 812 ▶ if ($self->{'char'} eq $self->{'quote'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"char"} eq $self->{"quote"}) 34 778 812
258 34 $self->{'spec_stay'} = $self->{'old_stay'};
259 34 $self->{'quote'} = $EMPTY_STR;
260 }
261 812 push @{$self->{'data'}}, $self->{'char'};
262  
263 } elsif ($self->{'char'} eq ']') {
264 13 push @{$self->{'data'}}, $self->{'char'};
265 13 $self->{'brace'}--;
266  
267 # Next character in normal tag (name).
268 ▶ } elsif ($self->{'tag_length'} > 1
Condition100%3/3
$self->{"tag_length"} > 1 and _is_in_tag_name($self->{"char"})
!ll&&!rl&&r
193661409
MC/DC100%2/2
$self->{"tag_length"} > 1 and _is_in_tag_name($self->{"char"})
$self->{"tag_length"} > 1 _is_in_tag_name($self->{"char"})
Truth table100%3/3
A and B
A= $self->{"tag_length"} > 1B= _is_in_tag_name($self->{"char"})
ABresult
0X0
100
111
269 && _is_in_tag_name($self->{'char'})) {
270  
271 # Comment detect.
272 409 ▶ if (($self->{'tag_length'} == 2
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tag_length"} == 2 || $self->{"tag_length"} == 3 and $self->{"char"} eq "-") 6 403 409
Condition100%6/6
$self->{"tag_length"} == 2 || $self->{"tag_length"} == 3 and $self->{"char"} eq "-"
!ll&&!rl&&r
2821216
$self->{"tag_length"} == 2 or $self->{"tag_length"} == 3
l!l&&r!l&&!r
6463282
MC/DC100%3/3
$self->{"tag_length"} == 2 || $self->{"tag_length"} == 3 and $self->{"char"} eq "-"
$self->{"tag_length"} == 2 $self->{"tag_length"} == 3 $self->{"char"} eq "-"
Truth table100%5/5
A or B and C
A= $self->{"tag_length"} == 2B= $self->{"tag_length"} == 3C= $self->{"char"} eq "-"
ABCresult
00X0
1X00
0100
1X11
0111
273 || $self->{'tag_length'} == 3)
274 && $self->{'char'} eq q{-}) {
275  
276 6 $self->{'spec_stay'}++;
277 }
278 409 ▶ if ($self->{'char'} eq '[') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"char"} eq "[") 7 402 409
279 7 $self->{'brace'}++;
280 }
281 409 push @{$self->{'data'}}, $self->{'char'};
282 409 $self->{'tag_length'}++;
283  
284 # Other characters.
285 } else {
286 1997 ▶ if ($self->{'quote'} eq $EMPTY_STR
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"quote"} eq $EMPTY_STR and $self->{"char"} eq "\"") 30 1967 1997
Condition66%2/3
$self->{"quote"} eq $EMPTY_STR and $self->{"char"} eq "\""
!ll&&!rl&&r
0196730
MC/DC50%1/2
$self->{"quote"} eq $EMPTY_STR and $self->{"char"} eq "\""
$self->{"quote"} eq $EMPTY_STR $self->{"char"} eq "\""
Truth table66%2/3
A and B
A= $self->{"quote"} eq $EMPTY_STRB= $self->{"char"} eq "\""
ABresult
0X0
100
111
287 && $self->{'char'} eq q{"}) {
288  
289 30 $self->{'quote'} = q{"};
290 30 $self->{'old_stay'} = $self->{'spec_stay'};
291 30 $self->{'spec_stay'} = 4;
292 }
293 1997 ▶ if ($self->{'quote'} eq $EMPTY_STR
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"quote"} eq $EMPTY_STR and $self->{"char"} eq "'") 4 1993 1997
Condition100%3/3
$self->{"quote"} eq $EMPTY_STR and $self->{"char"} eq "'"
!ll&&!rl&&r
3019634
MC/DC100%2/2
$self->{"quote"} eq $EMPTY_STR and $self->{"char"} eq "'"
$self->{"quote"} eq $EMPTY_STR $self->{"char"} eq "'"
Truth table100%3/3
A and B
A= $self->{"quote"} eq $EMPTY_STRB= $self->{"char"} eq "'"
ABresult
0X0
100
111
294 && $self->{'char'} eq q{'}) {
295  
296 4 $self->{'quote'} = q{'};
297 4 $self->{'old_stay'} = $self->{'spec_stay'};
298 4 $self->{'spec_stay'} = 4;
299 }
300 1997 ▶ if ($self->{'char'} eq '<') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"char"} eq "<") 22 1975 1997
301 22 $self->{'bracket'}++;
302 }
303 1997 ▶ if ($self->{'char'} eq '[') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"char"} eq "[") 5 1992 1997
304 5 $self->{'brace'}++;
305 }
306 1997 $self->_tag_type;
307 1997 push @{$self->{'data'}}, $self->{'char'};
308 }
309 }
310  
311 # Remove char from buffer.
312 4469 ▶ if ($self->{'stay'} != 99) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'stay'} != 99) { } 4414 55 4469
313 4414 ▶ if (exists $self->{'text'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"text"}) 689 3725 4414
314 689 ▶ if (length $self->{'text'} > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $self->{'text'} > 1) { } 689 0 689
315 689 $self->{'text'} = substr $self->{'text'}, 1;
316 } else {
317 0 delete $self->{'text'};
318 }
319 }
320 } else {
321 55 ▶ if (exists $self->{'filename'}
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"filename"} and defined $self->{"char"}) 55 0 55
Condition33%1/3
exists $self->{"filename"} and defined $self->{"char"}
!ll&&!rl&&r
0055
MC/DC0%0/2
exists $self->{"filename"} and defined $self->{"char"}
exists $self->{"filename"} defined $self->{"char"}
Truth table33%1/3
A and B
A= exists $self->{"filename"}B= defined $self->{"char"}
ABresult
0X0
100
111
322 && defined $self->{'char'}) {
323  
324 55 push @{$self->{'old_data'}}, $self->{'char'};
325 }
326 }
327 4469 ▶ if ($self->{'stay'} == 98 || $self->{'stay'} == 99) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"stay"} == 98 or $self->{"stay"} == 99) 166 4303 4469
Condition100%3/3
$self->{"stay"} == 98 or $self->{"stay"} == 99
l!l&&r!l&&!r
111554303
MC/DC100%2/2
$self->{"stay"} == 98 or $self->{"stay"} == 99
$self->{"stay"} == 98 $self->{"stay"} == 99
Truth table100%3/3
A or B
A= $self->{"stay"} == 98B= $self->{"stay"} == 99
ABresult
1X1
011
000
328 166 ▶ if ($self->{'stay'} == 99) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"stay"} == 99) 55 111 166
329 55 $self->{'charpos'}--;
330 }
331 }
332  
333 # Next line.
334 4469 ▶ if ($self->{'char'} eq "\n") {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"char"} eq "\n") 89 4380 4469
335 89 $self->{'textline'}++;
336 89 $self->{'charpos'} = 0;
337 }
338  
339 4469 return;
340 }
341  
342 # First character in tag.
343 sub _is_first_char_of_tag {
344 111 ▶ my $char = shift;
Subroutine _is_first_char_of_tag: called CC=5 SCAR=16.5
345 111 ▶ if ($char eq q{!} || $char eq q{/} || $char eq q{?}
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq "!" or $char eq "/" or $char eq "?" or $char =~ /^[\d\w]+$/ms) 29 0 29
Condition88%8/9
$char eq "!" or $char eq "/" or $char eq "?" or $char =~ /^[\d\w]+$/ms
l!l&&r!l&&!r
89220
$char eq "!" or $char eq "/" or $char eq "?"
l!l&&r!l&&!r
82722
$char eq "!" or $char eq "/"
l!l&&r!l&&!r
641829
MC/DC0%0/4
$char eq "!" or $char eq "/" or $char eq "?" or $char =~ /^[\d\w]+$/ms
$char eq "!" $char eq "/" $char eq "?" $char =~ /^[\d\w]+$/ms
Truth table80%4/5
A or B or C or D
A= $char eq "!"B= $char eq "/"C= $char eq "?"D= $char =~ /^[\d\w]+$/ms
ABCDresult
1XXX1
01XX1
001X1
00011
00000
346 || $char =~ /^[\d\w]+$/ms) {
347  
348 111 return 1;
349 }
350 0 return 0;
351 }
352  
353 # Normal characters in a tag name.
354 sub _is_in_tag_name {
355 732 ▶ my $char = shift;
Subroutine _is_in_tag_name: called CC=6 SCAR=17.9
356 732 ▶ if ($char eq q{:} || $char eq '[' || $char eq q{-} || $char eq q{%}
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq ":" or $char eq "[" or $char eq "-" or $char eq "%" or $char =~ /^[\d\w]+$/ms) 639 76 715
Condition100%12/12
$char eq ":" or $char eq "[" or $char eq "-" or $char eq "%" or $char =~ /^[\d\w]+$/ms
l!l&&r!l&&!r
1863876
$char eq ":" or $char eq "[" or $char eq "-" or $char eq "%"
l!l&&r!l&&!r
171714
$char eq ":" or $char eq "[" or $char eq "-"
l!l&&r!l&&!r
116715
$char eq ":" or $char eq "["
l!l&&r!l&&!r
47721
MC/DC100%5/5
$char eq ":" or $char eq "[" or $char eq "-" or $char eq "%" or $char =~ /^[\d\w]+$/ms
$char eq ":" $char eq "[" $char eq "-" $char eq "%" $char =~ /^[\d\w]+$/ms
Truth table100%6/6
A or B or C or D or E
A= $char eq ":"B= $char eq "["C= $char eq "-"D= $char eq "%"E= $char =~ /^[\d\w]+$/ms
ABCDEresult
1XXXX1
01XXX1
001XX1
0001X1
000011
000000
357 || $char =~ /^[\d\w]+$/ms) {
358  
359 656 return 1;
360 }
361 76 return 0;
362 }
363  
364 # Process tag type.
365 sub _tag_type {
366 2431 ▶ my $self = shift;
Subroutine _tag_type: called CC=2 SCAR=6.9
367 2431 ▶ if ($self->{'tag_length'} > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tag_length"} > 0) 111 2320 2431
368 $self->{'tag_type'}
369 111 = lc join $EMPTY_STR, @{$self->{'data'}}
370 111 [1 .. $self->{'tag_length'} - 1];
371 111 $self->{'tag_length'} = 0;
372 }
373 2431 return;
374 }
375  
376 14 1;
377  
378 __END__
↑ Summary