Branch Coverage

lib/Text/PO.pm
Criterion Covered Total %
branch 197 460 42.8


line true false branch
30 0 5 eval q[DateTime::TimeZone->new( name => 'local' );] ? :
100 0 0 if ($self->_is_a($_[0], 'Text::PO::Element')) { }
112 0 0 unless length $msgid
116 0 0 if $e2->is_meta or $e2->is_include
117 0 0 if ($e2->msgid_as_text eq $msgid)
125 0 0 if ($id) { }
131 0 0 if $elem->is_meta
132 0 0 if ($elem->is_include and ($elem->file // "") eq $id or not $elem->is_include and ($elem->id // "") eq $id)
135 0 0 if ($opts->{'after'}) { }
0 0 elsif ($opts->{'before'}) { }
147 0 0 unless ($found)
149 0 0 $opts->{'before'} ? :
164 0 0 if ($self->_is_a($_[0], 'Text::PO::Element')) { }
167 0 0 unless ($e->file)
176 0 0 unless ($opts->{'file'})
187 0 0 unless $elem->is_include
188 0 0 if (($elem->file // "") eq $file)
196 0 0 if ($id) { }
202 0 0 if $elem->is_meta
203 0 0 if ($elem->is_include and ($elem->file // "") eq $id or not $elem->is_include and ($elem->id // "") eq $id)
206 0 0 if ($opts->{'after'}) { }
0 0 elsif ($opts->{'before'}) { }
218 0 0 unless ($found)
220 0 0 $opts->{'before'} ? :
256 0 8 if $e->is_meta or not length($msgid // "")
260 1 7 if ($e->plural) { }
265 2 0 ref $msgstr->[$i] ? :
271 1 6 ref $msgstr ? :
279 1 7 if $e->plural and $e->msgid_plural
280 8 0 unless (scalar @{$ref->{'comment'} = $e->comment;})
284 8 0 unless (length($ref->{'context'} = $e->context))
288 8 0 unless (scalar @{$ref->{'flags'} = $e->flags;})
292 5 3 unless (length($ref->{'reference'} = $e->reference))
302 0 4 if exists $opts->{$t}
304 0 1 if exists $opts->{'sort'}
311 0 1 if ($@)
332 0 2 if (@_)
349 2 0 unless exists $ENV{'LANGUAGE'} or exists $ENV{'LANG'}
350 0 0 $ENV{'LANGUAGE'} || $ENV{'LANG'} ? :
357 0 0 unless length $str
359 0 0 unless $enc
364 0 0 if $enc eq "utf8"
367 0 0 if ($@)
381 1 0 if (@_) { }
384 0 1 unless &Scalar::Util::openhandle($fh)
392 0 1 if lc $enc eq "utf-8"
393 0 1 unless $fh->binmode(":$enc")
397 0 0 unless ($self->{'_parsed'} or scalar keys %{$$self{"meta"};})
403 1 0 if (my $header = $self->header)
405 0 1 unless $fh->print(join("\n", @$header))
408 1 0 if $self->domain
409 1 0 if (length $domain)
411 0 1 unless $fh->print(qq[\n#\n# domain "$domain"])
413 0 1 unless $fh->print("\n\n")
416 1 0 if (scalar @$metaKeys)
418 0 1 unless $fh->printf("msgid \"\"\n")
419 0 1 unless $fh->printf("msgstr \"\"\n")
430 0 11 unless exists $self->{'meta'}{$k2}
431 0 11 unless $fh->printf("\"%s: %s\\n\"\n", $self->normalise_meta($k), $self->meta($k))
433 0 1 unless $fh->print("\n")
438 0 8 if ($e->is_include) { }
440 0 0 unless $fh->print($e->dump, "\n")
444 0 8 if $e->is_meta or not length $msgid or ref($msgid // "") eq "ARRAY" and not scalar @$msgid
445 0 8 if ($e->po ne $self)
447 0 0 if $self->_is_warnings_enabled
449 0 8 unless $fh->print($e->dump, "\n")
451 0 8 unless $fh->print("\n")
464 0 1 unless $self->_is_a($elem, "Text::PO::Element")
469 0 1 unless $elem->is_include or length $elem->msgid_as_text
472 0 1 if ($e->is_include) { }
1 0 elsif ($opts->{'msgid_only'} and ($e->msgid_as_text // '') eq ($elem->msgid_as_text // '') or ($e->msgid_as_text // '') eq ($elem->msgid_as_text // '') and ($e->msgstr_as_text // '') eq ($elem->msgstr_as_text // '')) { }
474 0 0 if (($e->file // "") eq ($elem->file // ""))
482 0 1 if (length $elem->context) { }
484 0 0 if ($elem->context eq $e->context)
538 68 7 if (@_)
540 11 57 if ($self->_is_hash($_[0])) { }
57 0 elsif (scalar @_ == 1) { }
0 0 elsif (not @_ % 2) { }
567 38 10 if (index($k, "-") != -1)
581 1 3 if (@_)
584 0 1 unless $self->_is_array($ref)
594 0 4 unless scalar @$data
611 9 0 if not $opts->{'encoding'} and $self->encoding
622 47 0 if (scalar @res)
636 0 15 if (builtin::reftype($this) eq 'GLOB') { }
0 15 elsif (index($this, "\n") != -1) { }
639 0 0 unless &Scalar::Util::openhandle($io)
663 6 9 exists $opts->{'include'} ? :
667 6 9 exists $opts->{'max_recurse'} ? :
686 9 0 if ($source and $source->file) { }
698 1 8 unless ($inc_file->exists)
703 1 0 if $self->_is_warnings_enabled
710 1 7 if (exists $$seen_inc{"$inc_file"})
714 1 0 if $self->_is_warnings_enabled
722 7 0 $source && $source->file ? :
724 1 6 if ($depth + 1 > $max_recurse)
726 1 0 if $self->_is_warnings_enabled
741 0 6 unless ($me)
748 0 2 if (defined $lang and defined $sub_lang and lc $lang ne lc $sub_lang)
750 0 0 if $self->_is_warnings_enabled
754 5 1 if ($sub_elems and @$sub_elems)
761 0 9 if ++$seen->{$id} > 1
774 29 13 if (/^\S+/) { }
0 26 elsif ($ignoring_leading_blanks and /^[[:blank:]\h]*$/) { }
783 15 27 unless /^\#+/
784 6 21 if (/^\#+[[:blank:]]*(?:\.[[:blank:]]*)?\$include[[:blank:]]+(["'])(.+?)\1$/i) { }
2 19 elsif (/^\#+[[:blank:]\h]*domain[[:blank:]]+\"([^\"]+)\"/) { }
787 6 0 if ($include)
789 0 6 unless &$include_file($inc_name, $_, $n)
807 11 4 if length $header
813 15 213 if (not $foundFirstLine and /^\S/)
817 47 181 if (/^[[:blank:]]*$/) { }
0 181 elsif (/^\#\.[[:blank:]]*(?<text>(?!.*\$include[[:blank:]]+["'][^"']*["']).*?)$/i) { }
9 172 elsif (/^\#\:[[:blank:]]+(.*?)$/) { }
0 172 elsif (/^\#\,[[:blank:]]+(.*?)$/) { }
6 166 elsif (/^\#+(.*?)$/) { }
44 122 elsif (/^msgid[[:blank:]]+"(.*?)"$/) { }
3 119 elsif (/^msgid_plural[[:blank:]]+"(.*?)"[[:blank:]]*$/) { }
2 117 elsif (/^msgctxt[[:blank:]]+"(.*?)"[[:blank:]]*$/) { }
42 75 elsif (/^msgstr[[:blank:]]+"(.*?)"[[:blank:]]*$/) { }
8 67 elsif (/^msgstr\[(\d+)\][[:blank:]]+"(.*?)"[[:blank:]]*$/) { }
65 2 elsif (/^[[:blank:]]*"(.*?)"[[:blank:]]*$/) { }
0 2 elsif (/^\#[[:blank:]\h]*$/) { }
819 47 0 if ($foundFirstLine)
822 0 47 if (scalar @$elem > 1 and not length $e->msgid_as_text and length $e->msgstr_as_text and length $elem->[-1]->msgid_as_text and not length $elem->[-1]->msgstr_as_text) { }
1 46 elsif ($e->is_include) { }
836 6 40 if (++$$seen{$e->id // ''} > 1) { }
1 39 elsif (not $e->id || length($e->msgstr // '')) { }
851 18 23 if $self->encoding
856 10 31 if (scalar @$elem == 1)
866 47 0 if ($s =~ /^([^\x00-\x1f\x80-\xff :=]+):[[:blank:]]*(.*?)$/)
871 3 44 if ($k eq "content-type")
873 3 0 if ($v =~ /\bcharset=\s*([-\w]+)/i)
878 3 0 if lc $enc eq "utf-8"
884 3 0 $enc eq 'utf8' ? :
886 0 3 if ($@)
894 10 0 if (scalar keys %$meta)
896 10 0 if exists $meta->{'language'} and defined $meta->{'language'} and length($meta->{'language'} // "")
922 0 0 if $c
937 4 2 if ($c =~ /^(?:(?:\.[[:blank:]]*)|[[:blank:]]+)\$include[[:blank:]]+(["'])(.+?)\1/i)
940 3 1 if ($include) { }
942 0 3 unless &$include_file($inc_name, $c)
956 0 3 if (not $self->meta->length and $c =~ /^domain[[:blank:]\h]+\"(.*?)\"/) { }
1 2 elsif ($c =~ /^\.[[:blank:]]*(.*?)$/) { }
977 29 15 if length $1
988 3 0 if length $1
1004 2 0 if length $1
1009 26 16 if length $1
1014 8 0 if (length $2)
1024 65 0 if ($e->can($sub)) { }
1026 65 0 if length $1
1039 2 0 if $self->_is_warnings_enabled
1042 15 0 unless $fh_was_open
1043 14 1 if (scalar @$elem) { }
0 1 elsif ($e->msgid // '') { }
1045 3 11 if ($elem->[-1] ne $e and length $e->msgid_as_text and ++$$seen{$e->msgid_as_text} < 2)
1051 10 4 if $elem->[0]->is_meta
1069 0 4 unless ($strp)
1085 0 2 unless defined $s and length $s
1086 0 2 @_ ? :
1091 4 2 if (defined $_) { }
1106 2 0 if ($attribute =~ /^[a-zA-Z][a-zA-Z0-9\_\-]+$/ and length $attribute <= 255)
1108 2 0 if ($value =~ /^[a-zA-Z][a-zA-Z0-9\_\-]+$/ and length $value <= 255)
1122 0 0 if ($self->{'use_json'} and -e "$this.json" || $this =~ /\.json$/) { }
1124 0 0 -e "$this.json" ? :
1137 0 0 if ($@)
1150 0 0 unless $self->parse($this)
1160 2 0 if ($self->{'use_json'} and -e "$this.json" || $this =~ /\.json$/) { }
1162 0 2 -e "$this.json" ? :
1175 0 2 if ($@)
1180 0 2 if length $ref->{'domain'} and not length $self->domain
1182 2 0 if ($ref->{'meta_keys'}) { }
0 0 elsif ($ref->{'meta'}) { }
1191 2 0 if ($ref->{'meta'})
1203 2 0 if (scalar @$meta_keys)
1220 2 14 if ($def->{'msgid_plural'})
1224 2 14 if (ref $def->{'msgstr'} eq 'ARRAY') { }
1235 0 16 if $def->{'comment'}
1236 0 16 if $def->{'context'}
1237 0 16 if $def->{'flags'}
1238 6 10 if $def->{'reference'}
1239 0 16 if $self->encoding
1253 0 2 if (@_) { }
1261 0 0 if $self->{'plural'} and scalar @{$self->{'plural'};}
1264 2 0 if ($pluralDef)
1266 2 0 if ($pluralDef =~ /^[[:blank:]\h]*nplurals[[:blank:]\h]*=[[:blank:]\h]*(\d+)[[:blank:]\h]*\;[[:blank:]\h]*plural[[:blank:]\h]*=[[:blank:]\h]*(.*?)\;?$/i) { }
1294 0 21 unless length $str
1309 0 0 unless defined $rv
1310 0 0 unless $rv
1315 0 0 if ($elems->[$i] eq $elem)
1334 0 0 if (not exists $self->{'meta'}{$k2} and length $Text::PO::DEF_META->{$k})
1351 0 0 if scalar @_ and @_ % 2 || !(@_ % 2) && ref $_[1] eq 'HASH'
1353 0 0 unless length $this
1354 0 0 unless ($this)
1357 0 0 if ($fh = $self->source->handle) { }
0 0 elsif (my $file = $self->source->file) { }
1359 0 0 if $self->_can_write_fh($fh)
1363 0 0 if -e $file and -w $file
1366 0 0 unless $this
1368 0 0 unless $self->dump($fh)
1373 0 0 if (builtin::reftype($this) eq 'GLOB') { }
0 0 elsif (-l $this) { }
0 0 elsif (-e $this) { }
1375 0 0 unless &Scalar::Util::openhandle($this)
1376 0 0 unless $self->_can_write_fh($this)
1385 0 0 unless (-f $this)
1398 0 0 unless $self->dump($fh)
1408 0 0 unless &Scalar::Util::openhandle($fh)
1423 0 0 if (not $self->exists($e, {'msgid_only', 1})) { }
1426 0 0 if $removedObj
1441 0 0 if (not $po->exists($e, {'msgid_only', 1})) { }
1443 0 0 if ($e->is_include) { }
1459 0 0 unless $fh->seek(0, 0)
1461 0 0 unless $po->dump($fh)
1472 0 133 unless length $str
1497 0 0 if ($flags & 3 & 3)
1508 0 4 if (@_) { }
1511 0 0 if (ref $v and $self->_is_a($v, "DateTime"))
1526 0 4 unless (defined $meta and length $meta)
1538 0 27 if (@_)
1581 0 2 unless length $value
1592 0 0 unless (defined $self->{'original'} and length $self->{'original'})
1595 0 0 if (defined $self->{'value'} and length $self->{'value'})
1597 0 0 unless ($self->{'value'} =~ /^$Text::PO::HeaderValue::TYPE_REGEXP$/)
1605 0 0 if ($self->{'params'} and ref $self->{'params'} eq "HASH")
1610 0 0 unless ($params->[$i] =~ /^$Text::PO::HeaderValue::TOKEN_REGEXP$/)
1614 0 0 if (length $string > 0)
1632 2 0 if (@_)
1646 0 0 if ($str =~ /^$Text::PO::HeaderValue::TOKEN_REGEXP$/)
1651 0 0 if (length $str > 0 and not $str =~ /^$Text::PO::HeaderValue::TEXT_REGEXP$/)