Branch Coverage

blib/lib/Gedcom/Item.pm
Criterion Covered Total %
branch 129 198 65.1


line true false branch
32 8 9321 if $self->{'file'} and $self->{'file'} ne '*'
40 0 0 if exists $self->{$key}
50 0 0 if exists $self->{$key}
61 0 8 unless open $fh, $self->{'file'}
67 0 8 if ($line1 =~ /^\xEF\xBB\xBF/) { }
72 8 62 if (my($char) = /\s*1\s+CHAR\s+(.*?)\s*$/i)
73 0 8 $char =~ /utf\W*8/i ? :
80 7 1 if $self->{'gedcom'}
81 0 8 if ($encoding eq 'utf-8' and $] >= 5.8) { }
92 0 8 $bom ? :
101 0 8 if $callback and not &$callback($title, $txt1, "Record $count", tell $fh, $size)
104 7 1 $self->{'grammar'} ? :
108 1 1 if ($self->{'gedcom'}{'read_only'} and defined($gf = -M $self->{'file'}) and defined($gc = -M $if) and $gc < $gf)
111 0 1 if (not open(I, $if)) { }
127 144 2 if length $vals[1]
128 2 144 if length $vals[2]
130 140 6 if $class
133 0 1 unless close I
137 7 1 unless (@{$self->{'items'};})
144 876 29 if ($self->{'grammar'}) { }
148 876 0 if (@g) { }
153 0 0 unless defined $tag and length $tag
166 0 905 if ref $item and $callback and not &$callback($title, $txt1, "Record $count line " . $item->{'line'}, tell $fh, $size)
176 1 1 if ($self->{'gedcom'}{'read_only'} and defined $gf and !defined($gc) || $gc > $gf)
178 0 1 if (not open(I, ">$if")) { }
182 146 584 unless $item->{$_}
186 0 1 unless close I
197 2378 10998 if (not $parse and $item->{'level'} >= 0 and $self->{'gedcom'}{'read_only'} and $self->{'gedcom'}{'grammar'}) { }
204 3110 0 if ($parse and $self->{'gedcom'}{'read_only'} and $self->{'gedcom'}{'grammar'})
206 3110 0 if (defined $item->{'cpos'})
213 73 8389 unless (ref $next)
220 200 8189 if (not defined $next_level or $next_level <= $level) { }
225 0 8189 if $next_level > $level + 1
231 7688 3110 unless $item->{'gedcom'}{'read_only'}
245 4079 443 if (my($lev) = $l =~ /^\s*(\d+)/)
246 2377 1702 if ($lev <= $level)
265 200 19972 if ($rec = $self->{'stored_item'}) { }
18783 1189 elsif (not $rec && $rec->{'level'} and my $line = $self->next_text_line) { }
271 29 18754 if (my($structure) = $line =~ /^\s*(\w+): =\s*$/) { }
18681 73 elsif (my($level, $xref, $tag, $value, $space, $min, $max, $star) = $line =~ /^\s* # optional whitespace at start ((?:\+?\d+)|n) # start level \s* # optional whitespace (?: # xref (\@?@) # text in @?@ \s+ # whitespace )? # optional (?: # tag (?!<<) # don't match a type ([\w\s\[\]\|<>]+?) # non greedy \s+ # whitespace )? # optional (?: # value ( # (?: # one of \@??\@? # text element - non greedy | # or \[\s* # start list (?: # \@?<.*>\@? # text element \s*\|?\s* # optionally delimited )+ # one or more \] # end list ) # ) # (\s+) # whitespace )?? # optional - non greedy (?: # value \{ # open brace (\d+) # min : # : (\d+|M) # max \*? # optional * [\}\]] # close brace or bracket )? # optional (\*?\s*) # optional * and ws at end $/x) { }
73 0 elsif ($line =~ m(^\s*[\[\|\]]\s*(?:/\*.*\*/\s*)?$)) { }
330 9065 9616 if ($level eq 'n' or $level > $item->{'level'}) { }
331 9065 0 unless ($rec)
334 8688 377 if $self->{'gedcom'}{'grammar'}
336 95 8970 $level eq 'n' ? :
9065 0 if defined $level
337 872 0 $xref =~ /^\@(.+)\@$/ ? :
872 8193 if defined $xref
339 8942 123 if defined $tag
340 6697 319 if defined $space and $self->{'grammar'}
341 8688 377 if defined $star and $self->{'grammar'}
342 9007 58 if defined $value
344 1822 7185 ($rec->{'pointer'} = $value =~ /^\@(.+)\@$/) ? :
9007 58 if defined $value
348 377 8688 if defined $min
349 377 8688 if defined $max
368 9094 200 if $rec and defined $rec->{'level'} and $rec->{'level'} > $item->{'level'}
392 7640 7 unless $flush or $level < 0
394 872 6775 if defined $self->{'xref'} and length $self->{'xref'}
395 7640 7 if $level >= 0
401 1028 4259 $self->resolve_xref($self->{'value'}) ? :
516 5287 ref $self->{'value'} ? :
5803 1844 if defined $self->{'value'} and length $self->{'value'}
403 7640 7 unless $level < 0
407 879 6761 if $level < 0 and $c < @{$self->{'items'};} - 1
415 0 0 if $self->{'tag'} and $self->{'tag'} =~ /^(CON[CT]|TRLR)$/
420 0 0 unless $level
428 0 0 ref $self->{'value'} ? :
0 0 $self->{'value'} ? :
430 0 0 if defined $value
435 0 0 if ($tag)
440 0 0 $events && defined $self->{'gedcom'}{'types'}{$self->{'tag'}} && $self->{'gedcom'}{'types'}{$self->{'tag'}} eq 'Event' ? :
442 0 0 if $tag eq 'GEDCOM'
447 0 0 if ($tag eq 'EVEN') { }
0 0 elsif ($tag =~ /^(FAM[SC]|HUSB|WIFE|CHIL|SUBM|NOTE)$/ and defined $value and $self->resolve_xref($self->{'value'})) { }
0 0 elsif ($self->{'xref'}) { }
454 0 0 unless $sub_items
459 0 0 unless defined $value or $tag
464 0 0 if $sub_items or not $spaced and !(defined $value || $tag) || $tag eq 'EVEN' || $self->{'xref'}
467 0 0 if (defined $value)
468 0 0 if $spaced or $sub_items
470 0 0 if $spaced or $sub_items
479 0 0 if ($tag)
480 0 0 if $spaced or $sub_items
488 0 0 if defined $self->{$v}
496 55487 10071 if (wantarray and not $count) { }
499 10069 2 unless $count
501 10071 484 if $c->{'tag'} eq $tag and not --$count
530 1 7 if $i eq "$_"
541 0 1 unless $parent
552 3 13 if $i eq "$_"
556 0 3 unless $n < @{$self->{'items'};}
560 2 1 if defined $item->{'xref'}
569 8 31211 if @_
577 66257 0 if defined $value
579 164 0 defined $item->{'value'} ? :
581 24 140 if $item->{'tag'} eq 'CONT'
582 12 152 if $item->{'tag'} eq 'CONC'
590 4282 234484 if not defined $self->{'_items'} and $self->{'level'} >= 0