Regexp/Dumper.pm

filter: Statementstmt 75.5% 259 / 343 Branchbran 54.1% 118 / 218 Conditioncond 45.9% 34 / 74 MC/DCmcdc 17.0% 8 / 47 Subroutinesub 85.0% 34 / 40 Podpod 100% 4 / 4 totaltotal 62.9% 457 / 726 CC 163 SCAR 31.0
CC
163
Cov
65%
__PPIX_DUMPER__dump
54.0
new
35.4
__PPIX_DUMPER__dump
31.6
CRAP 22.2
↑ Summary Regexp/Token/Interpolation.pm »
1 =head1 NAME
2  
3 PPIx::Regexp::Dumper - Dump the results of parsing regular expressions
4  
5 =head1 SYNOPSIS
6  
7 use PPIx::Regexp::Dumper;
8 PPIx::Regexp::Dumper->new( 'qr{foo}smx' )
9 ->print();
10  
11 =head1 INHERITANCE
12  
13 C<PPIx::Regexp::Dumper> is a
14 L<PPIx::Regexp::Support|PPIx::Regexp::Support>.
15  
16 C<PPIx::Regexp::Dumper> has no descendants.
17  
18 =head1 DESCRIPTION
19  
20 This class generates a formatted dump of a
21 L<PPIx::Regexp::Element|PPIx::Regexp::Element> object (or any subclass
22 thereof), a L<PPIx::Regexp::Tokenizer|PPIx::Regexp::Tokenizer>
23 object, or a string that can be made into one of these.
24  
25 =head1 METHODS
26  
27 This class provides the following public methods. Methods not documented
28 here are private, and unsupported in the sense that the author reserves
29 the right to change or remove them without notice.
30  
31 =cut
32  
33 package PPIx::Regexp::Dumper;
34  
35 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
36 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
37  
38 6 ▶use base qw{ PPIx::Regexp::Support };
Subroutine BEGIN: called CC=1 SCAR=0.0
39  
40 6 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
41 6 ▶use Scalar::Util qw{ blessed looks_like_number };
Subroutine BEGIN: called CC=1 SCAR=0.0
42  
43 6 ▶use PPIx::Regexp;
Subroutine BEGIN: called CC=1 SCAR=0.0
44 6 ▶use PPIx::Regexp::Constant qw{
Subroutine BEGIN: called CC=1 SCAR=0.0
45 ARRAY_REF
46 INFINITY
47 @CARP_NOT
48 6 };
49 6 ▶use PPIx::Regexp::Tokenizer;
Subroutine BEGIN: called CC=1 SCAR=0.0
50 6 ▶use PPIx::Regexp::Util qw{ __choose_tokenizer_class __instance };
Subroutine BEGIN: called CC=1 SCAR=0.0
51  
52 6 our $VERSION = '0.092';
53  
54 6 ▶use constant LOCATION_WIDTH => 19;
Subroutine BEGIN: called CC=1 SCAR=0.0
55  
56 =head2 new
57  
58 my $dumper = PPIx::Regexp::Dumper->new(
59 '/foo/', ordinal => 1,
60 );
61  
62 This static method instantiates the dumper. It takes the string,
63 L<PPI::Element|PPI::Element>,
64 L<PPIx::Regexp::Element|PPIx::Regexp::Element>, or
65 L<PPIx::Regexp::Tokenizer|PPIx::Regexp::Tokenizer> to be dumped as the
66 first argument. Optional further arguments may be passed as name/value
67 pairs.
68  
69 The following options are recognized:
70  
71 =over
72  
73 =item default_modifiers array_reference
74  
75 This argument is a reference to a list of default modifiers to be
76 applied to the statement being parsed. See L<PPIx::Regexp|PPIx::Regexp>
77 L<new()|PPIx::Regexp/new> for the details.
78  
79 =item encoding name
80  
81 This argument is the name of the encoding of the regular expression. If
82 specified, it is passed through to
83 L<< PPIx::Regexp->new()|PPIx::Regexp/new >>. It also causes an
84 C<Encode::encode> to be done on any parse content dumped.
85  
86 =item explain Boolean
87  
88 If true, this option causes the C<explain()> output of each object to be
89 dumped.
90  
91 =item indent number
92  
93 This argument is the number of additional spaces to indent each level of
94 the parse hierarchy. This is ignored if either the C<test> or C<tokens>
95 argument is true.
96  
97 The default is 2.
98  
99 =item margin number
100  
101 This is the number of spaces to indent the top level of the parse
102 hierarchy. This is ignored if the C<test> argument is true.
103  
104 The default is zero.
105  
106 =item ordinal Boolean
107  
108 If true, this option causes the C<ordinal> values of
109 L<PPIx::Regexp::Token::Literal|PPIx::Regexp::Token::Literal> objects to
110 be dumped.
111  
112 =item perl_version Boolean
113  
114 If true, this option causes the C<perl_version_introduced> and
115 C<perl_version_removed> values associated with each object dumped to be
116 displayed.
117  
118 =item ppi Boolean
119  
120 If true, any Perl code contained in the object will be dumped.
121  
122 =item short Boolean
123  
124 If true, leading C<'PPIx::Regexp::'> will be removed from the class
125 names in the output.
126  
127 =item strict Boolean
128  
129 This option is passed on to the parser, where it specifies whether the
130 parse should assume C<use re 'strict'> is in effect.
131  
132 The C<'strict'> pragma was introduced in Perl 5.22, and its
133 documentation says that it is experimental, and that there is no
134 commitment to backward compatibility. The same applies to the
135 parse produced when this option is asserted.
136  
137 The default is false.
138  
139 =item significant Boolean
140  
141 If true, this option causes only significant elements to be dumped.
142  
143 The default is false.
144  
145 =item test Boolean
146  
147 If true, this option causes the output to be formatted as a regression
148 test rather than as a straight dump. The output produced by asserting
149 this option is explicitly undocumented, in the sense that the author
150 reserves the right to change the generated output without notice of any
151 kind.
152  
153 The default is false.
154  
155 =item tokens Boolean
156  
157 If true, this option causes a dump of tokenizer output rather than of a
158 full parse of the regular expression. This is forced true if the dump is
159 of a L<PPIx::Regexp::Tokenizer|PPIx::Regexp::Tokenizer>.
160  
161 The default is false.
162  
163 =item trace number
164  
165 If greater than zero, this option causes a trace of the parse. This
166 option is unsupported in the sense that the author reserves the right to
167 change it without notice.
168  
169 The default is zero.
170  
171 =item verbose number
172  
173 If greater than zero, this option causes additional information to be
174 given about the elements found. This option is unsupported in the sense
175 that the author reserves the right to change it without notice.
176  
177 The default is zero.
178  
179 =item width Boolean
180  
181 If true, this option causes a dump of the width of the object.
182  
183 =back
184  
185 If the thing to be dumped was a string, unrecognized arguments are
186 passed to C<< PPIx::Regexp::Tokenizer->new() >>. Otherwise they are
187 ignored.
188  
189 =cut
190  
191 {
192  
193 6 my %default = (
194 explain => 0,
195 indent => 2,
196 locations => 0,
197 margin => 0,
198 ordinal => 0,
199 perl_version => 0,
200 ppi => 0,
201 short => 0,
202 significant => 0,
203 test => 0,
204 tokens => 0,
205 verbose => 0,
206 width => 0,
207 );
208  
209 6 ▶ sub new {
Subroutine new: called CC=18 SCAR=35.7
Pod documented
210 6 my ( $class, $re, %args ) = @_;
211 6 ▶ ref $class and $class = ref $class;
Branch: 1 branch
BranchTrueFalseTotal
ref $class and $class = ref $class 0 6 6
212  
213 my $self = {
214 encoding => $args{encoding},
215 lister => undef,
216 object => undef,
217 source => $re,
218 strict => $args{strict},
219 6 };
220  
221 6 foreach my $key ( qw{ default_modifiers parse } ) {
222 exists $args{$key}
223 12 ▶ and $self->{$key} = $args{$key};
Branch: 1 branch
BranchTrueFalseTotal
exists $args{$key} and $self->{$key} = $args{$key} 0 12 12
224 }
225  
226 6 foreach my $key ( keys %default ) {
227 $self->{$key} = exists $args{$key} ?
228 delete $args{$key} :
229 78 ▶ $default{$key};
Branch: 1 branch
BranchTrueFalseTotal
exists $args{$key} ? : 9 69 78
230 }
231  
232 6 ▶ $self->{ordinal} ||= $self->{verbose};
Condition100%3/3
$self->{"ordinal"} ||= $self->{"verbose"}
l!l&&r!l&&!r
132
MC/DC100%2/2
$self->{"ordinal"} ||= $self->{"verbose"}
$self->{"ordinal"} $self->{"verbose"}
Truth table100%3/3
A ||= B
A= $self->{"ordinal"}B= $self->{"verbose"}
ABresult
1X1
011
000
233  
234 6 ▶ if ( __instance( $re, 'PPIx::Regexp::Tokenizer' ) ) {
Branch: 5 branches
BranchTrueFalseTotal
if (__instance($re, 'PPIx::Regexp::Tokenizer')) { } 2 4 6
elsif (__instance($re, 'PPIx::Regexp::Element')) { } 3 1 4
elsif ('ARRAY' eq ref $re) { } 0 1 1
elsif (ref $re and not __instance($re, 'PPI::Element')) { } 0 1 1
elsif ($self->{'tokens'}) { } 0 1 1
235 2 $self->{object} = $re;
236 2 $self->{tokens} = 1;
237 } elsif ( __instance( $re, 'PPIx::Regexp::Element' ) ) {
238 3 $self->{object} = $re;
239 } elsif ( ARRAY_REF eq ref $re ) {
240 0 $self->{object} = $re;
241 ▶ } elsif ( ref $re && ! __instance( $re, 'PPI::Element' ) ) {
Condition33%1/3
ref $re and not __instance($re, "PPI::Element")
!ll&&!rl&&r
100
MC/DC0%0/2
ref $re and not __instance($re, "PPI::Element")
ref $re not __instance($re, "PPI::Element")
Truth table33%1/3
A and not(B)
A= ref $reB= not __instance($re, "PPI::Element")
ABresult
0X0
100
111
242 0 croak "Do not know how to dump ", ref $re;
243 } elsif ( $self->{tokens} ) {
244 0 ▶ my $tokenizer_class = __choose_tokenizer_class( $re, \%args )
Branch: 1 branch
BranchTrueFalseTotal
my $tokenizer_class = __choose_tokenizer_class($re, \%args) or croak("Unsupported data type") 0 0 0
245 or croak 'Unsupported data type';
246 __instance( $re, 'PPI::Element' )
247 0 ▶ or $args{location} = [ 1, 1, 1, 1, undef ];
Branch: 1 branch
BranchTrueFalseTotal
__instance($re, "PPI::Element") or $args{"location"} = [1, 1, 1, 1, undef] 0 0 0
248 $self->{object} =
249 0 ▶ $tokenizer_class->new( $re, %args )
Branch: 1 branch
BranchTrueFalseTotal
$self->{"object"} = $tokenizer_class->new($re, %args) or Carp::croak($tokenizer_class->errstr) 0 0 0
250 or Carp::croak( $tokenizer_class->errstr() );
251 } else {
252 __instance( $re, 'PPI::Element' )
253 1 ▶ or $args{location} = [ 1, 1, 1, 1, undef ];
Branch: 1 branch
BranchTrueFalseTotal
__instance($re, "PPI::Element") or $args{"location"} = [1, 1, 1, 1, undef] 0 1 1
254 $self->{object} =
255 1 ▶ PPIx::Regexp->new( $re, %args )
Branch: 1 branch
BranchTrueFalseTotal
$self->{"object"} = "PPIx::Regexp"->new($re, %args) or Carp::croak("PPIx::Regexp"->errstr) 1 0 1
256 or Carp::croak( PPIx::Regexp->errstr() );
257 }
258  
259 6 bless $self, $class;
260  
261 6 return $self;
262  
263 }
264  
265 }
266  
267 =head2 list
268  
269 print map { "$_\n" } $dumper->list();
270  
271 This method produces an array containing the dump output, one line per
272 element. The output has no left margin applied, and no newlines.
273  
274 =cut
275  
276 6 ▶sub list {
Subroutine list: called CC=3 SCAR=11.6
Pod documented
277 5 my ( $self ) = @_;
278 5 ▶ my $lister = $self->{test} ? '__PPIX_DUMPER__test' : '__PPIX_DUMPER__dump';
Branch: 1 branch
BranchTrueFalseTotal
$self->{'test'} ? : 2 3 5
279  
280 ARRAY_REF eq ref $self->{object}
281 0 ▶ and return ( map { $_->$lister( $self ) } @{ $self->{object} } );
Branch: 1 branch
BranchTrueFalseTotal
"ARRAY" eq ref $self->{"object"} and return map({$_->$lister($self);} @{$$self{"object"};}) 0 5 5
282  
283 5 return $self->{object}->$lister( $self );
284 }
285  
286 =head2 print
287  
288 $dumper->print();
289  
290 This method simply prints the result of L</string> to standard out.
291  
292 =cut
293  
294 0 ▶sub print : method { ## no critic (ProhibitBuiltinHomonyms)
Subroutine print: not called CC=1 SCAR=1.2
Pod documented
295 0 my ( $self ) = @_;
296 # Non-characters and Non-Unicode code points are explicitly allowed
297 # as delimiters, at least as of 5.29.0, which is where unassigned
298 # and combining code points became illegal. Unfortunately the
299 # warnings below were not introduced until 5.14, so have to go for
300 # the next-higher warning category.
301 # no warnings qw{ nonchar non_unicode }; ## no critic (ProhibitNoWarnings)
302 6 ▶ no warnings qw{ utf8 }; ## no critic (ProhibitNoWarnings)
Subroutine BEGIN: called CC=1 SCAR=0.0
303 0 print $self->string();
304 0 return;
305 }
306  
307 =head2 string
308  
309 print $dumper->string();
310  
311 This method adds left margin and newlines to the output of L</list>,
312 concatenates the result into a single string, and returns that string.
313  
314 =cut
315  
316 5 ▶sub string {
Subroutine string: called CC=1 SCAR=0.0
Pod documented
317 5 my ( $self ) = @_;
318 5 my $margin = ' ' x $self->{margin};
319 return join( '',
320 5 map { $margin . $_ . "\n" } $self->list() );
321 }
322  
323 # quote a string.
324 131 ▶sub _safe {
Subroutine _safe: called CC=6 SCAR=18.0
325 131 my ( $self, @args ) = @_;
326 131 my @rslt;
327 131 foreach my $item ( @args ) {
328 196 ▶ if ( blessed( $item ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($item)) 40 156 196
329 40 $item = $self->encode( $item->content() );
330 }
331 196 ▶ if ( ! defined $item ) {
Branch: 3 branches
BranchTrueFalseTotal
if (not defined $item) { } 0 196 196
elsif ('ARRAY' eq ref $item) { } 41 155 196
elsif (&looks_like_number($item)) { } 48 107 155
332 0 push @rslt, 'undef';
333 } elsif ( ARRAY_REF eq ref $item ) {
334 41 push @rslt, join( ' ', '[', $self->_safe( @{ $item } ), ']' );
335 } elsif ( looks_like_number( $item ) ) {
336 48 push @rslt, $item;
337 } else {
338 107 $item =~ s/ ( [\\'] ) /\\$1/smxg;
339 107 push @rslt, "'$item'";
340 }
341 }
342 131 my $rslt = join( ', ', @rslt );
343 131 return $rslt
344 }
345  
346 0 ▶sub _safe_version {
Subroutine _safe_version: not called CC=2 SCAR=17.9
347 0 my ( undef, $version ) = @_; # Invocant unused
348 0 ▶ return defined $version ? "'$version'" : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $version ? : 0 0 0
349 }
350  
351 28 ▶sub __nav {
Subroutine __nav: called CC=1 SCAR=0.0
352 28 my ( $self, @args ) = @_;
353 28 my $rslt = $self->_safe( @args );
354 28 $rslt =~ s/ ' (\w+) ' , /$1 =>/smxg;
355 28 $rslt =~ s/ \[ \s+ \] /[]/smxg;
356 28 $rslt =~ s/ \[ \s* ( [0-9]+ ) \s* \] /$1/smxg;
357 28 return $rslt;
358 }
359  
360 7 ▶sub _perl_version {
Subroutine _perl_version: called CC=1 SCAR=0.0
361 7 my ( undef, $elem ) = @_; # Invocant unused
362  
363 7 return $elem->requirements_for_perl();
364 }
365  
366 20 ▶sub _ppi {
Subroutine _ppi: called CC=3 SCAR=19.2
367 20 my ( $self, $elem ) = @_;
368  
369 $self->{ppi}
370 20 ▶ and $elem->can( 'ppi' )
Branch: 1 branch
BranchTrueFalseTotal
$self->{"ppi"} and $elem->can("ppi") or return 0 20 20
Condition33%1/3
$self->{"ppi"} and $elem->can("ppi")
!ll&&!rl&&r
2000
MC/DC0%0/2
$self->{"ppi"} and $elem->can("ppi")
$self->{"ppi"} $elem->can("ppi")
Truth table33%1/3
A and B
A= $self->{"ppi"}B= $elem->can("ppi")
ABresult
0X0
100
111
371 or return;
372  
373 0 require PPI::Dumper;
374  
375 # PPI::Dumper reports line_number(), but I want
376 # logical_line_number(). There is no configuration for this, but the
377 # interface is public, so I mung it to do what I want.
378 0 my $locn = PPI::Element->can( 'location' );
379 0 ▶ local *PPI::Element::location = sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
380 0 my $loc = $locn->( @_ );
381 0 $loc->[0] = $loc->[3];
382 0 return $loc;
383 0 };
384  
385 my $dumper = PPI::Dumper->new( $elem->ppi(),
386 0 map { $_ => $self->{$_} } qw{ indent locations },
387 );
388  
389 0 return $dumper->list();
390 }
391  
392 22 ▶sub _content {
Subroutine _content: called CC=7 SCAR=20.5
393 22 my ( $self, $elem, $dflt ) = @_;
394 22 ▶ defined $dflt or $dflt = '';
Branch: 1 branch
BranchTrueFalseTotal
defined $dflt or $dflt = "" 0 22 22
395  
396 22 ▶ defined $elem or return $dflt;
Branch: 1 branch
BranchTrueFalseTotal
defined $elem or return $dflt 22 0 22
397 22 ▶ if ( ARRAY_REF eq ref $elem ) {
Branch: 1 branch
BranchTrueFalseTotal
if ("ARRAY" eq ref $elem) 11 11 22
398 my $rslt = join '',
399 11 map { $self->_content( $_ ) }
400 11 ▶ grep { ! $self->{significant} || $_->significant() }
Condition33%1/3
!$self->{'significant'} || $_->significant
l!l&&r!l&&!r
1100
MC/DC0%0/2
!$self->{'significant'} || $_->significant
!$self->{'significant'} $_->significant
Truth table33%1/3
not(A) || B
A= !$self->{'significant'}B= $_->significant
ABresult
1X1
011
000
401 11 @{ $elem };
402 11 ▶ return $rslt eq '' ? $dflt : $rslt;
Branch: 1 branch
BranchTrueFalseTotal
$rslt eq '' ? : 0 11 11
403 }
404 11 ▶ blessed( $elem ) or return $dflt;
Branch: 1 branch
BranchTrueFalseTotal
builtin::blessed($elem) or return $dflt 11 0 11
405 11 return $self->encode( $elem->content() );
406 }
407  
408 1 ▶sub _tokens_dump {
Subroutine _tokens_dump: called CC=6 SCAR=20.3
409 1 my ( $self, $elem, $depth ) = @_;
410  
411 1 ▶ not $self->{significant} or $elem->significant() or return;
Branch: 1 branch
BranchTrueFalseTotal
not $self->{"significant"} or $elem->significant or return 1 0 1
Condition33%1/3
not $self->{"significant"} or $elem->significant
l!l&&r!l&&!r
100
MC/DC0%0/2
not $self->{"significant"} or $elem->significant
not $self->{"significant"} $elem->significant
Truth table33%1/3
not(A) or B
A= not $self->{"significant"}B= $elem->significant
ABresult
1X1
011
000
412  
413 1 my @rslt;
414 1 foreach my $token ( $elem->tokens() ) {
415 7 ▶ not $self->{significant} or $token->significant() or next;
Branch: 1 branch
BranchTrueFalseTotal
not $self->{"significant"} or $token->significant or next 7 0 7
Condition33%1/3
not $self->{"significant"} or $token->significant
l!l&&r!l&&!r
700
MC/DC0%0/2
not $self->{"significant"} or $token->significant
not $self->{"significant"} $token->significant
Truth table33%1/3
not(A) or B
A= not $self->{"significant"}B= $token->significant
ABresult
1X1
011
000
416 7 push @rslt, $token->__PPIX_DUMPER__dump( $self, $depth );
417 }
418 1 return @rslt;
419 }
420  
421 2 ▶sub _format_default_modifiers {
Subroutine _format_default_modifiers: called CC=5 SCAR=24.1
422 2 my ( $self, $subr, $elem ) = @_;
423 2 my @arg = $self->_safe( $elem );
424 2 foreach my $attr ( qw{ default_modifiers parse strict } ) {
425 6 ▶ defined ( my $val = $self->{$attr} )
Branch: 1 branch
BranchTrueFalseTotal
defined(my $val = $self->{$attr}) or next 0 6 6
426 or next;
427 ARRAY_REF eq ref $val
428 0 ▶ and not @{ $val }
Branch: 1 branch
BranchTrueFalseTotal
"ARRAY" eq ref $val and not @{$val;} and next 0 0 0
Condition0%0/3
"ARRAY" eq ref $val and not @{$val;}
!ll&&!rl&&r
000
MC/DC0%0/2
"ARRAY" eq ref $val and not @{$val;}
"ARRAY" eq ref $val not @{$val;}
Truth table0%0/3
A and not(B)
A= "ARRAY" eq ref $valB= not @{$val;}
ABresult
0X0
100
111
429 and next;
430 0 push @arg, "$attr => @{[ $self->_safe( $val ) ]}";
431 }
432 2 return sprintf '%-8s( %s );', $subr, join ', ', @arg;
433 }
434  
435 12 ▶sub _format_matcher_dump {
Subroutine _format_matcher_dump: called CC=3 SCAR=11.1
436 12 my ( undef, $elem ) = @_;
437 12 my $value = $elem->is_matcher();
438 12 ▶ return sprintf 'is_matcher=%s',
Branch: 2 branches
BranchTrueFalseTotal
$value ? : 9 3 12
defined $value ? : 3 0 3
439 $value ? 'true' : defined $value ? 'false' : 'undef';
440 }
441  
442 1 ▶sub _format_modifiers_dump {
Subroutine _format_modifiers_dump: called CC=5 SCAR=17.2
443 1 my ( undef, $elem ) = @_; # Invocant unused
444 1 my %mods = $elem->modifiers();
445 1 my @accum;
446 $mods{match_semantics}
447 and push @accum, 'match_semantics=' . delete
448 1 ▶ $mods{match_semantics};
Branch: 1 branch
BranchTrueFalseTotal
$mods{"match_semantics"} and push @accum, 'match_semantics=' . delete $mods{"match_semantics"} 0 1 1
449 1 foreach my $modifier ( sort keys %mods ) {
450 1 ▶ push @accum, $mods{$modifier} ? $modifier :
Branch: 1 branch
BranchTrueFalseTotal
$mods{$modifier} ? : 1 0 1
451 "-$modifier";
452 }
453 1 ▶ @accum and return join ' ', @accum;
Branch: 1 branch
BranchTrueFalseTotal
@accum and return join(" ", @accum) 1 0 1
454 0 return;
455 }
456  
457 0 ▶sub _format_width_dump {
Subroutine _format_width_dump: not called CC=5 SCAR=34.0
458 0 my @arg = @_;
459 0 foreach ( @arg ) {
460 0 ▶ if ( defined ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_) { } 0 0 0
461 0 ▶ $_ == INFINITY
Branch: 1 branch
BranchTrueFalseTotal
$_ == "Inf" and $_ = "'Inf'" 0 0 0
462 and $_ = q<'Inf'>;
463 } else {
464 0 $_ = 'undef';
465 }
466 }
467 wantarray
468 0 ▶ and return @arg;
Branch: 1 branch
BranchTrueFalseTotal
wantarray and return @arg 0 0 0
469 0 return join ', ', @arg;
470 }
471  
472 0 ▶sub _format_width_test {
Subroutine _format_width_test: not called CC=5 SCAR=34.0
473 0 my @arg = @_;
474 0 foreach ( @arg ) {
475 0 ▶ if ( defined ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_) { } 0 0 0
476 0 ▶ $_ == INFINITY
Branch: 1 branch
BranchTrueFalseTotal
$_ == "Inf" and $_ = "INFINITY" 0 0 0
477 and $_ = 'INFINITY';
478 } else {
479 0 $_ = 'undef';
480 }
481 }
482 wantarray
483 0 ▶ and return @arg;
Branch: 1 branch
BranchTrueFalseTotal
wantarray and return @arg 0 0 0
484 0 return join ', ', @arg;
485 }
486  
487 1 ▶sub _tokens_test {
Subroutine _tokens_test: called CC=6 SCAR=19.6
488 1 my ( $self, $elem ) = @_;
489  
490 1 ▶ not $self->{significant} or $elem->significant() or return;
Branch: 1 branch
BranchTrueFalseTotal
not $self->{"significant"} or $elem->significant or return 1 0 1
Condition33%1/3
not $self->{"significant"} or $elem->significant
l!l&&r!l&&!r
100
MC/DC0%0/2
not $self->{"significant"} or $elem->significant
not $self->{"significant"} $elem->significant
Truth table33%1/3
not(A) or B
A= not $self->{"significant"}B= $elem->significant
ABresult
1X1
011
000
491  
492 1 my @tokens = $elem->tokens();
493  
494 1 my @rslt = (
495 $self->_format_default_modifiers( tokenize => $elem ),
496 sprintf( 'count ( %d );', scalar @tokens ),
497 );
498  
499 1 my $inx = 0;
500 1 foreach my $token ( @tokens ) {
501 9 ▶ not $self->{significant} or $token->significant() or next;
Branch: 1 branch
BranchTrueFalseTotal
not $self->{"significant"} or $token->significant or next 9 0 9
Condition33%1/3
not $self->{"significant"} or $token->significant
l!l&&r!l&&!r
900
MC/DC0%0/2
not $self->{"significant"} or $token->significant
not $self->{"significant"} $token->significant
Truth table33%1/3
not(A) or B
A= not $self->{"significant"}B= $token->significant
ABresult
1X1
011
000
502 9 push @rslt, $token->__PPIX_DUMPER__test( $self, $inx++ );
503 }
504 1 return @rslt;
505 }
506  
507 0 ▶sub PPIx::Regexp::Element::__PPIX_DUMPER__dump_explanation {
Subroutine __PPIX_DUMPER__dump_explanation: not called CC=5 SCAR=34.0
508 0 my ( $self, undef, $line ) = @_; # $dumper unused
509 0 ▶ my @expl = $self->explain()
Branch: 1 branch
BranchTrueFalseTotal
my(@expl) = $self->explain or return $line 0 0 0
510 or return $line;
511 0 ▶ 1 == @expl
Branch: 1 branch
BranchTrueFalseTotal
1 == @expl and return "$line\t$expl[0]" 0 0 0
512 and return "$line\t$expl[0]";
513 wantarray
514 0 ▶ or return sprintf "%s\t%s", $line, join '; ', @expl;
Branch: 1 branch
BranchTrueFalseTotal
wantarray or return sprintf("%s\t%s", $line, join("; ", @expl)) 0 0 0
515 0 ( my $blank = $line ) =~ s/\S/ /smxg;
516 0 my @rslt;
517 0 foreach my $splain ( @expl ) {
518 0 push @rslt, "$line\t$splain";
519 0 $line = $blank;
520 }
521 0 return @rslt;
522 }
523  
524 1 ▶sub PPIx::Regexp::__PPIX_DUMPER__test {
Subroutine __PPIX_DUMPER__test: called CC=4 SCAR=14.6
525 1 my ( $self, $dumper ) = @_;
526  
527 $dumper->{tokens}
528 1 ▶ and return $dumper->_tokens_test( $self );
Branch: 1 branch
BranchTrueFalseTotal
$dumper->{"tokens"} and return $dumper->_tokens_test($self) 0 1 1
529  
530 1 ▶ not $dumper->{significant} or $self->significant() or return;
Branch: 1 branch
BranchTrueFalseTotal
not $dumper->{"significant"} or $self->significant or return 1 0 1
Condition33%1/3
not $dumper->{"significant"} or $self->significant
l!l&&r!l&&!r
100
MC/DC0%0/2
not $dumper->{"significant"} or $self->significant
not $dumper->{"significant"} $self->significant
Truth table33%1/3
not(A) or B
A= not $dumper->{"significant"}B= $self->significant
ABresult
1X1
011
000
531  
532 # my $parse = 'parse ( ' . $dumper->_safe( $self ) . ' );';
533 1 my $parse = $dumper->_format_default_modifiers( parse => $self );
534 1 my $fail = 'value ( failures => [], ' . $self->failures() . ' );';
535  
536 # Note that we can not use SUPER in the following because SUPER goes
537 # by the current package, not by the class of the object.
538 1 my @rslt = PPIx::Regexp::Node::__PPIX_DUMPER__test( $self, $dumper );
539  
540 # Get rid of the empty choose();
541 1 shift @rslt;
542  
543 1 return ( $parse, $fail, @rslt );
544 }
545  
546 3 ▶sub PPIx::Regexp::Node::__PPIX_DUMPER__dump {
Subroutine __PPIX_DUMPER__dump: called CC=14 SCAR=28.7
547 3 my ( $self, $dumper, $depth ) = @_;
548  
549 3 ▶ $depth ||= 0;
Condition100%2/2
$depth ||= 0
l!l
12
MC/DC100%1/1
$depth ||= 0
$depth
Truth table100%2/2
A
A= $depth
Aresult
11
00
550  
551 $dumper->{tokens}
552 3 ▶ and return $dumper->_tokens_dump( $self, $depth );
Branch: 1 branch
BranchTrueFalseTotal
$dumper->{"tokens"} and return $dumper->_tokens_dump($self, $depth) 0 3 3
553  
554 3 ▶ not $dumper->{significant} or $self->significant() or return;
Branch: 1 branch
BranchTrueFalseTotal
not $dumper->{"significant"} or $self->significant or return 3 0 3
Condition33%1/3
not $dumper->{"significant"} or $self->significant
l!l&&r!l&&!r
300
MC/DC0%0/2
not $dumper->{"significant"} or $self->significant
not $dumper->{"significant"} $self->significant
Truth table33%1/3
not(A) or B
A= not $dumper->{"significant"}B= $self->significant
ABresult
1X1
011
000
555  
556 3 my @rslt = ( ref $self );
557 $dumper->{short}
558 3 ▶ and $rslt[0] =~ s/ \A PPIx::Regexp:: //smx;
Branch: 1 branch
BranchTrueFalseTotal
$dumper->{"short"} and $rslt[0] =~ s/ \A PPIx::Regexp:: //msx 0 3 3
559 $self->isa( 'PPIx::Regexp' )
560 and $rslt[-1] .= $dumper->{verbose}
561 3 ▶ ? sprintf "\tfailures=%d\tmax_capture_number=%d",
Branch: 2 branches
BranchTrueFalseTotal
$self->isa("PPIx::Regexp") and $rslt[-1] .= $dumper->{"verbose"} ? sprintf("\tfailures=%d\tmax_capture_number=%d", $self->failures, $self->max_capture_number) : sprintf("\tfailures=%d", $self->failures) 2 1 3
$dumper->{'verbose'} ? : 1 1 2
562 $self->failures(), $self->max_capture_number()
563 : sprintf "\tfailures=%d", $self->failures();
564  
565 3 substr $rslt[0], 0, 0, ' ' x ( $depth * $dumper->{indent} );
566  
567 $dumper->{locations}
568 3 ▶ and substr $rslt[0], 0, 0, ' ' x LOCATION_WIDTH;
Branch: 1 branch
BranchTrueFalseTotal
$dumper->{"locations"} and substr $rslt[0], 0, 0, " " 0 3 3
569  
570 3 ▶ if ( $dumper->{width} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dumper->{"width"}) 0 3 3
571 0 my $width = _format_width_dump( $self->width() );
572 0 $rslt[-1] .= "\t{ $width }";
573 }
574  
575 $dumper->{perl_version}
576 3 ▶ and $rslt[-1] .= "\t" . $dumper->_perl_version( $self );
Branch: 1 branch
BranchTrueFalseTotal
$dumper->{"perl_version"} and $rslt[-1] .= "\t" . $dumper->_perl_version($self) 1 2 3
577  
578 3 ▶ if ( defined ( my $err = $self->error() ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $err = $self->error)) { } 0 3 3
579 0 $rslt[-1] .= "\t$err";
580 } else {
581 $dumper->{explain}
582 3 ▶ and push @rslt, $self->__PPIX_DUMPER__dump_explanation(
Branch: 1 branch
BranchTrueFalseTotal
$dumper->{"explain"} and push @rslt, $self->__PPIX_DUMPER__dump_explanation($dumper, pop @rslt) 0 3 3
583 $dumper, pop @rslt );
584 }
585  
586 3 $depth++;
587 3 foreach my $elem ( $self->children() ) {
588 9 push @rslt, $elem->__PPIX_DUMPER__dump( $dumper, $depth );
589 }
590 3 return @rslt;
591 }
592  
593 2 ▶sub PPIx::Regexp::Node::__PPIX_DUMPER__test {
Subroutine __PPIX_DUMPER__test: called CC=8 SCAR=26.1
594 2 my ( $self, $dumper ) = @_;
595  
596 2 ▶ not $dumper->{significant} or $self->significant() or return;
Branch: 1 branch
BranchTrueFalseTotal
not $dumper->{"significant"} or $self->significant or return 2 0 2
Condition33%1/3
not $dumper->{"significant"} or $self->significant
l!l&&r!l&&!r
200
MC/DC0%0/2
not $dumper->{"significant"} or $self->significant
not $dumper->{"significant"} $self->significant
Truth table33%1/3
not(A) or B
A= not $dumper->{"significant"}B= $self->significant
ABresult
1X1
011
000
597  
598 2 my @rslt;
599 2 @rslt = (
600 'choose ( ' . $dumper->__nav( $self->nav() ) . ' );',
601 'klass ( ' . $dumper->_safe( ref $self ) . ' );',
602 'count ( ' . scalar $self->children() . ' );',
603 );
604  
605 2 ▶ if ( defined( my $err = $self->error() ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $err = $self->error)) 0 2 2
606  
607 0 push @rslt,
608 'error ( ' . $dumper->_safe( $err ) . ' );';
609  
610 }
611  
612 2 ▶ if ( $dumper->{width} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dumper->{"width"}) 0 2 2
613 0 my $raw = _format_width_test( $self->raw_width() );
614 0 my $width = _format_width_test( $self->width() );
615 0 push @rslt,
616 "raw_width( $raw );",
617 "width ( $width );";
618 }
619  
620 2 ▶ if ( $dumper->{perl_version} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dumper->{"perl_version"}) 0 2 2
621 0 foreach my $method ( qw{
622 perl_version_introduced
623 perl_version_removed
624 } ) {
625 0 push @rslt, "value ( $method => [], " .
626 $dumper->_safe_version( $self->$method() ) . ' );';
627 }
628 }
629 2 foreach my $elem ( $self->children() ) {
630 6 push @rslt, $elem->__PPIX_DUMPER__test( $dumper );
631 }
632 2 return @rslt;
633 }
634  
635 3 ▶sub _format_value {
Subroutine _format_value: called CC=3 SCAR=12.0
636 3 my ( $val ) = @_;
637 3 ▶ defined $val
Branch: 1 branch
BranchTrueFalseTotal
defined $val or return "undef" 2 1 3
638 or return 'undef';
639 2 ▶ $val =~ m/ \A [0-9]+ \z /smx
Branch: 1 branch
BranchTrueFalseTotal
$val =~ / \A [0-9]+ \z /msx and return $val 2 0 2
640 and return $val;
641 0 $val =~ s/ (?= [\\"] ) /\\/smxg;
642 0 return qq{"$val"};
643 }
644  
645 {
646  
647 6 my %dflt = (
648 start => '???',
649 type => '',
650 finish => '???',
651 );
652  
653 5 ▶ sub PPIx::Regexp::Structure::__PPIX_DUMPER__dump {
Subroutine __PPIX_DUMPER__dump: called CC=24 SCAR=34.5
654 5 my ( $self, $dumper, $depth ) = @_;
655  
656 5 ▶ $depth ||= 0;
Condition50%1/2
$depth ||= 0
l!l
50
MC/DC0%0/1
$depth ||= 0
$depth
Truth table50%1/2
A
A= $depth
Aresult
11
00
657  
658 5 ▶ not $dumper->{significant} or $self->significant() or return;
Branch: 1 branch
BranchTrueFalseTotal
not $dumper->{"significant"} or $self->significant or return 5 0 5
Condition33%1/3
not $dumper->{"significant"} or $self->significant
l!l&&r!l&&!r
500
MC/DC0%0/2
not $dumper->{"significant"} or $self->significant
not $dumper->{"significant"} $self->significant
Truth table33%1/3
not(A) or B
A= not $dumper->{"significant"}B= $self->significant
ABresult
1X1
011
000
659  
660 5 my @delim;
661 5 foreach my $method ( qw{ start type finish } ) {
662 15 my @elem = $self->$method();
663 15 ▶ push @delim, @elem ? $dumper->_content( \@elem ) : $dflt{$method};
Branch: 1 branch
BranchTrueFalseTotal
@elem ? : 11 4 15
664 }
665 5 my @rslt = ( ref $self, "$delim[0]$delim[1] ... $delim[2]" );
666 $dumper->{short}
667 5 ▶ and $rslt[0] =~ s/ \A PPIx::Regexp:: //smx;
Branch: 1 branch
BranchTrueFalseTotal
$dumper->{"short"} and $rslt[0] =~ s/ \A PPIx::Regexp:: //msx 0 5 5
668  
669 5 substr $rslt[0], 0, 0, ' ' x ( $depth * $dumper->{indent} );
670  
671 $dumper->{locations}
672 5 ▶ and substr $rslt[0], 0, 0, ' ' x LOCATION_WIDTH;
Branch: 1 branch
BranchTrueFalseTotal
$dumper->{"locations"} and substr $rslt[0], 0, 0, " " 0 5 5
673  
674 $dumper->{perl_version}
675 5 ▶ and push @rslt, $dumper->_perl_version( $self );
Branch: 1 branch
BranchTrueFalseTotal
$dumper->{"perl_version"} and push @rslt, $dumper->_perl_version($self) 2 3 5
676  
677 5 ▶ if ( $dumper->{width} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dumper->{"width"}) 0 5 5
678 0 my $width = _format_width_dump( $self->width() );
679 0 push @rslt, "{ $width }";
680 }
681  
682 5 ▶ if ( $dumper->{verbose} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dumper->{"verbose"}) 3 2 5
683 3 foreach my $method ( qw{ number name max_capture_number } ) {
684 9 ▶ $self->can( $method ) or next;
Branch: 1 branch
BranchTrueFalseTotal
$self->can($method) or next 3 6 9
685 3 push @rslt, sprintf '%s=%s', $method, _format_value(
686 $self->$method() );
687 }
688 3 foreach my $method ( qw{ can_be_quantified is_quantifier } ) {
689 ## is_case_sensitive
690 6 ▶ $self->can( $method ) or next;
Branch: 1 branch
BranchTrueFalseTotal
$self->can($method) or next 6 0 6
691 6 ▶ $self->$method() and push @rslt, $method;
Branch: 1 branch
BranchTrueFalseTotal
$self->$method and push @rslt, $method 2 4 6
692 }
693 3 ▶ $self->isa( 'PPIx::Regexp::Structure::Modifier' )
Branch: 1 branch
BranchTrueFalseTotal
$self->isa("PPIx::Regexp::Structure::Modifier") and push @rslt, $dumper->_format_modifiers_dump($self->type(0)) 0 3 3
694 and push @rslt, $dumper->_format_modifiers_dump(
695 $self->type( 0 ) );
696  
697 3 push @rslt, $dumper->_format_matcher_dump( $self );
698 }
699  
700 5 foreach my $method ( 'start', undef, 'finish' ) {
701 15 ▶ my $ele = defined $method ? $self->$method() : $self
Branch: 2 branches
BranchTrueFalseTotal
my $ele = defined $method ? $self->$method : $self or next 15 0 15
defined $method ? : 10 5 15
702 or next;
703 15 ▶ if ( defined ( my $err = $ele->error() ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $err = $ele->error)) 0 15 15
704 0 push @rslt, $err;
705 }
706 }
707  
708 5 @rslt = ( join "\t", @rslt );
709  
710 $dumper->{explain}
711 5 ▶ and not defined $self->error()
Branch: 1 branch
BranchTrueFalseTotal
$dumper->{"explain"} and not defined $self->error and push @rslt, $self->__PPIX_DUMPER__dump_explanation($dumper, pop @rslt) 0 5 5
Condition33%1/3
$dumper->{"explain"} and not defined $self->error
!ll&&!rl&&r
500
MC/DC0%0/2
$dumper->{"explain"} and not defined $self->error
$dumper->{"explain"} not defined $self->error
Truth table33%1/3
A and not(B)
A= $dumper->{"explain"}B= not defined $self->error
ABresult
0X0
100
111
712 and push @rslt, $self->__PPIX_DUMPER__dump_explanation(
713 $dumper, pop @rslt );
714  
715 5 $depth++;
716 5 foreach my $elem ( $self->children() ) {
717 10 push @rslt, $elem->__PPIX_DUMPER__dump( $dumper, $depth );
718 }
719 5 return @rslt;
720 }
721  
722 }
723  
724 6 ▶sub PPIx::Regexp::Structure::__PPIX_DUMPER__test {
Subroutine __PPIX_DUMPER__test: called CC=11 SCAR=27.4
725 2 my ( $self, $dumper ) = @_;
726  
727 2 ▶ not $dumper->{significant} or $self->significant() or return;
Branch: 1 branch
BranchTrueFalseTotal
not $dumper->{"significant"} or $self->significant or return 2 0 2
Condition33%1/3
not $dumper->{"significant"} or $self->significant
l!l&&r!l&&!r
200
MC/DC0%0/2
not $dumper->{"significant"} or $self->significant
not $dumper->{"significant"} $self->significant
Truth table33%1/3
not(A) or B
A= not $dumper->{"significant"}B= $self->significant
ABresult
1X1
011
000
728  
729 2 my @nav = $self->nav();
730 2 my @rslt = (
731 'choose ( ' . $dumper->__nav( @nav ) . ' );',
732 'klass ( ' . $dumper->_safe( ref $self ) . ' );',
733 'count ( ' . scalar $self->children() . ' );',
734 );
735 2 ▶ if ( $dumper->{verbose} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dumper->{"verbose"}) 2 0 2
736 2 foreach my $method ( qw{ number name } ) {
737 4 ▶ $self->can( $method ) or next;
Branch: 1 branch
BranchTrueFalseTotal
$self->can($method) or next 0 4 4
738 0 push @rslt, 'value ( ' . $method . ' => [], ' .
739 $dumper->_safe( $self->$method() ) . ' );';
740 }
741 }
742  
743 2 ▶ if ( $dumper->{width} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dumper->{"width"}) 0 2 2
744 0 my $raw = _format_width_test( $self->raw_width() );
745 0 my $width = _format_width_test( $self->width() );
746 0 push @rslt,
747 "raw_width( $raw );",
748 "width ( $width );";
749 }
750  
751 2 foreach my $method ( qw{ start type finish } ) {
752 6 my @eles = $self->$method();
753 6 push @rslt, 'choose ( ' . $dumper->__nav(
754 @nav, $method, [] ) . ' );',
755 'count ( ' . scalar @eles . ' );';
756 6 foreach my $inx ( 0 .. $#eles ) {
757 4 my $elem = $eles[$inx];
758 4 ▶ push @rslt, 'choose ( ' . $dumper->__nav(
Condition33%1/3
ref $elem || $elem
l!l&&r!l&&!r
400
MC/DC0%0/2
ref $elem || $elem
ref $elem $elem
Truth table33%1/3
A || B
A= ref $elemB= $elem
ABresult
1X1
011
000
759 @nav, $method, $inx ) . ' );',
760 'klass ( ' . $dumper->_safe( ref $elem || $elem ) . ' );',
761 'content ( ' . $dumper->_safe( $elem ) . ' );';
762 }
763 }
764 2 foreach my $elem ( $self->children() ) {
765 2 push @rslt, $elem->__PPIX_DUMPER__test( $dumper );
766 }
767 2 return @rslt;
768 }
769  
770 1 ▶sub PPIx::Regexp::Tokenizer::__PPIX_DUMPER__dump {
Subroutine __PPIX_DUMPER__dump: called CC=2 SCAR=7.1
771 1 my ( $self, $dumper, $depth ) = @_;
772  
773 1 ▶ $depth ||= 0;
Condition50%1/2
$depth ||= 0
l!l
01
MC/DC0%0/1
$depth ||= 0
$depth
Truth table50%1/2
A
A= $depth
Aresult
11
00
774  
775 1 return $dumper->_tokens_dump( $self, $depth );
776  
777 }
778  
779 1 ▶sub PPIx::Regexp::Tokenizer::__PPIX_DUMPER__test {
Subroutine __PPIX_DUMPER__test: called CC=1 SCAR=0.0
780 1 my ( $self, $dumper ) = @_;
781  
782 1 return $dumper->_tokens_test( $self );
783 }
784  
785 20 ▶sub PPIx::Regexp::Token::__PPIX_DUMPER__dump {
Subroutine __PPIX_DUMPER__dump: called CC=27 SCAR=39.9
786 20 my ( $self, $dumper, $depth ) = @_;
787  
788 20 ▶ $depth ||= 0;
Condition100%2/2
$depth ||= 0
l!l
137
MC/DC100%1/1
$depth ||= 0
$depth
Truth table100%2/2
A
A= $depth
Aresult
11
00
789  
790 not $dumper->{significant}
791 20 ▶ or $self->significant()
Branch: 1 branch
BranchTrueFalseTotal
not $dumper->{"significant"} or $self->significant or return 20 0 20
Condition33%1/3
not $dumper->{"significant"} or $self->significant
l!l&&r!l&&!r
2000
MC/DC0%0/2
not $dumper->{"significant"} or $self->significant
not $dumper->{"significant"} $self->significant
Truth table33%1/3
not(A) or B
A= not $dumper->{"significant"}B= $self->significant
ABresult
1X1
011
000
792 or return;
793  
794 20 my @rslt = ( ref $self, $dumper->_safe( $self ) );
795 $dumper->{short}
796 20 ▶ and $rslt[0] =~ s/ \A PPIx::Regexp:: //smx;
Branch: 1 branch
BranchTrueFalseTotal
$dumper->{"short"} and $rslt[0] =~ s/ \A PPIx::Regexp:: //msx 0 20 20
797  
798 20 substr $rslt[0], 0, 0, ' ' x ( $depth * $dumper->{indent} );
799  
800 $dumper->{locations}
801 20 ▶ and substr $rslt[0], 0, 0,
Branch: 1 branch
BranchTrueFalseTotal
$dumper->{"locations"} and substr $rslt[0], 0, 0, sprintf("[ % 4d, % 3d, % 3d ] ", $self->logical_line_number, $self->column_number, $self->visual_column_number) 0 20 20
802 sprintf '[ % 4d, % 3d, % 3d ] ',
803 $self->logical_line_number(),
804 $self->column_number(),
805 $self->visual_column_number();
806  
807 20 my @ppi;
808 20 ▶ @ppi = $dumper->_ppi( $self )
Branch: 1 branch
BranchTrueFalseTotal
@ppi = $dumper->_ppi($self) and shift @ppi 0 20 20
809 and shift @ppi; # Ignore PPI::Document
810 20 foreach ( @ppi ) {
811 0 ▶ if ( $dumper->{locations} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dumper->{'locations'}) { } 0 0 0
812 0 ▶ s/ ( [0-9]+ \s+ \] ) /$1 /smxg
Branch: 1 branch
BranchTrueFalseTotal
s/ ( [0-9]+ \s+ \] ) /$1 /gmsx or substr $_, 0, 0, " " 0 0 0
813 or substr $_, 0, 0, ' ';
814 } else {
815 0 substr $_, 0, 0, ' ';
816 }
817 }
818  
819 20 ▶ if ( $dumper->{width} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dumper->{"width"}) 0 20 20
820 0 my $width = _format_width_dump( $self->width() );
821 0 push @rslt, "{ $width }";
822 }
823  
824 $dumper->{perl_version}
825 20 ▶ and push @rslt, $dumper->_perl_version( $self );
Branch: 1 branch
BranchTrueFalseTotal
$dumper->{"perl_version"} and push @rslt, $dumper->_perl_version($self) 4 16 20
826  
827 20 ▶ if ( defined( my $err = $self->error() ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $err = $self->error)) { } 0 20 20
828  
829 0 return join "\t", @rslt, $err;
830  
831 } else {
832  
833 20 ▶ if ( $dumper->{ordinal} && $self->can( 'ordinal' )
Branch: 1 branch
BranchTrueFalseTotal
if ($dumper->{"ordinal"} and $self->can("ordinal") and defined(my $ord = $self->ordinal)) 8 12 20
Condition83%5/6
$dumper->{"ordinal"} and $self->can("ordinal") and defined(my $ord = $self->ordinal)
!ll&&!rl&&r
1208
$dumper->{"ordinal"} and $self->can("ordinal")
!ll&&!rl&&r
488
MC/DC66%2/3
$dumper->{"ordinal"} and $self->can("ordinal") and defined(my $ord = $self->ordinal)
$dumper->{"ordinal"} $self->can("ordinal") defined(my $ord = $self->ordinal)
Truth table75%3/4
A and B and C
A= $dumper->{"ordinal"}B= $self->can("ordinal")C= defined(my $ord = $self->ordinal)
ABCresult
0XX0
10X0
1100
1111
834 && defined ( my $ord = $self->ordinal() ) ) {
835 8 push @rslt, sprintf '0x%02x', $ord;
836 }
837  
838 20 ▶ if ( $dumper->{verbose} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dumper->{"verbose"}) 9 11 20
839  
840 9 ▶ if ( $self->isa( 'PPIx::Regexp::Token::Reference' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->isa("PPIx::Regexp::Token::Reference")) 0 9 9
841 0 foreach my $method ( qw{ absolute name number } ) {
842 0 ▶ defined( my $val = $self->$method() ) or next;
Branch: 1 branch
BranchTrueFalseTotal
defined(my $val = $self->$method) or next 0 0 0
843 0 push @rslt, "$method=$val";
844 }
845 }
846  
847 9 foreach my $method (
848 qw{ significant can_be_quantified is_quantifier } ) {
849 ## is_case_sensitive
850 27 ▶ $self->can( $method )
Branch: 1 branch
BranchTrueFalseTotal
$self->can($method) and $self->$method and push @rslt, $method 16 11 27
Condition66%2/3
$self->can($method) and $self->$method
!ll&&!rl&&r
01116
MC/DC50%1/2
$self->can($method) and $self->$method
$self->can($method) $self->$method
Truth table66%2/3
A and B
A= $self->can($method)B= $self->$method
ABresult
0X0
100
111
851 and $self->$method()
852 and push @rslt, $method;
853 }
854  
855 9 ▶ $self->can( 'ppi' )
Branch: 1 branch
BranchTrueFalseTotal
$self->can("ppi") and push @rslt, $self->ppi->content 0 9 9
856 and push @rslt, $self->ppi()->content();
857  
858 9 ▶ if ( $self->isa( 'PPIx::Regexp::Token::Modifier' ) ||
Branch: 1 branch
BranchTrueFalseTotal
if ($self->isa("PPIx::Regexp::Token::Modifier") or $self->isa("PPIx::Regexp::Token::GroupType::Modifier")) 1 8 9
Condition66%2/3
$self->isa("PPIx::Regexp::Token::Modifier") or $self->isa("PPIx::Regexp::Token::GroupType::Modifier")
l!l&&r!l&&!r
108
MC/DC50%1/2
$self->isa("PPIx::Regexp::Token::Modifier") or $self->isa("PPIx::Regexp::Token::GroupType::Modifier")
$self->isa("PPIx::Regexp::Token::Modifier") $self->isa("PPIx::Regexp::Token::GroupType::Modifier")
Truth table66%2/3
A or B
A= $self->isa("PPIx::Regexp::Token::Modifier")B= $self->isa("PPIx::Regexp::Token::GroupType::Modifier")
ABresult
1X1
011
000
859 $self->isa( 'PPIx::Regexp::Token::GroupType::Modifier' )
860 ) {
861 1 push @rslt, $dumper->_format_modifiers_dump( $self );
862 }
863  
864 9 push @rslt, $dumper->_format_matcher_dump( $self );
865 }
866  
867 20 @rslt = ( join "\t", @rslt );
868  
869 $dumper->{explain}
870 20 ▶ and push @rslt, $self->__PPIX_DUMPER__dump_explanation(
Branch: 1 branch
BranchTrueFalseTotal
$dumper->{"explain"} and push @rslt, $self->__PPIX_DUMPER__dump_explanation($dumper, pop @rslt) 0 20 20
871 $dumper, pop @rslt );
872  
873 20 push @rslt, @ppi;
874  
875 20 return @rslt;
876 }
877 }
878  
879 14 ▶sub PPIx::Regexp::Token::__PPIX_DUMPER__test {
Subroutine __PPIX_DUMPER__test: called CC=13 SCAR=30.9
880 14 my ( $self, $dumper, @nav ) = @_;
881  
882 14 ▶ not $dumper->{significant} or $self->significant() or return;
Branch: 1 branch
BranchTrueFalseTotal
not $dumper->{"significant"} or $self->significant or return 14 0 14
Condition33%1/3
not $dumper->{"significant"} or $self->significant
l!l&&r!l&&!r
1400
MC/DC0%0/2
not $dumper->{"significant"} or $self->significant
not $dumper->{"significant"} $self->significant
Truth table33%1/3
not(A) or B
A= not $dumper->{"significant"}B= $self->significant
ABresult
1X1
011
000
883  
884 14 ▶ @nav or @nav = $self->nav();
Branch: 1 branch
BranchTrueFalseTotal
@nav or @nav = $self->nav 9 5 14
885 14 my @rslt = (
886 'choose ( ' . join(', ', $dumper->__nav( @nav ) ) . ' );',
887 'klass ( ' . $dumper->_safe( ref $self ) . ' );',
888 'content ( ' . $dumper->_safe( $self ) . ' );',
889 );
890  
891 14 ▶ if ( defined( my $err = $self->error() ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $err = $self->error)) { } 0 14 14
892  
893 0 push @rslt,
894 'error ( ' . $dumper->_safe( $err ) . ' );';
895  
896 } else {
897  
898 14 ▶ if ( $dumper->{perl_version} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dumper->{"perl_version"}) 0 14 14
899 0 foreach my $method ( qw{
900 perl_version_introduced
901 perl_version_removed
902 } ) {
903 0 push @rslt, "value ( $method => [], " .
904 $dumper->_safe_version( $self->$method() ) . ' );';
905 }
906 }
907  
908 14 ▶ if ( $dumper->{width} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dumper->{"width"}) 0 14 14
909 0 my $raw = _format_width_test( $self->raw_width() );
910 0 my $width = _format_width_test( $self->width() );
911 0 push @rslt,
912 "raw_width( $raw );",
913 "width ( $width );";
914 }
915  
916 14 ▶ if ( $dumper->{verbose} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dumper->{"verbose"}) 14 0 14
917  
918 14 foreach my $method (
919 qw{ significant can_be_quantified is_quantifier } ) {
920 ## is_case_sensitive
921 42 ▶ $self->can( $method ) or next;
Branch: 1 branch
BranchTrueFalseTotal
$self->can($method) or next 42 0 42
922 42 ▶ push @rslt, $self->$method() ?
Branch: 1 branch
BranchTrueFalseTotal
$self->$method ? : 21 21 42
923 "true ( $method => [] );" :
924 "false ( $method => [] );";
925 }
926  
927 14 ▶ $self->can( 'ppi' )
Branch: 1 branch
BranchTrueFalseTotal
$self->can("ppi") and push @rslt, 'value ( ppi => [], ' . $dumper->_safe($self->ppi) . ' );' 0 14 14
928 and push @rslt, "value ( ppi => [], " .
929 $dumper->_safe( $self->ppi() ) . ' );';
930  
931 }
932 }
933  
934 14 return @rslt;
935 }
936  
937 6 1;
938  
939 __END__
↑ Summary Regexp/Token/Interpolation.pm »