Branch Coverage

lib/HTTP/Promise/Stream.pm
Criterion Covered Total %
branch 170 408 41.6


line true false branch
631 0 0 unless defined $src or length $src
632 121 1 ref $src ? :
633 121 1 if (ref $src) { }
635 47 74 if ($self->_is_a($src, 'Module::Generic::File')) { }
0 79 elsif ($type ne 'scalar' and $type ne 'glob' and $type ne 'code') { }
646 0 1 if ($src =~ /\n/)
656 0 122 unless $self->SUPER::init(@_)
660 33 89 if (defined $self->{'encoding'} and length $self->{'encoding'}) { }
72 34 elsif (defined $self->{'decoding'} and length $self->{'decoding'}) { }
662 1 32 unless exists $HTTP::Promise::Stream::FILTER_MAP->{'encode'}{$self->{'encoding'}}
666 3 69 unless exists $HTTP::Promise::Stream::FILTER_MAP->{'decode'}{$self->{'decoding'}}
675 0 0 if (ref $src) { }
678 0 0 if ($type eq 'scalar') { }
0 0 elsif ($type eq 'glob') { }
0 0 elsif ($self->_is_a($src, 'Module::Generic::File')) { }
684 0 0 if ($self->_is_a($src, 'Module::Generic::Scalar::IO')) { }
0 0 elsif ($self->_is_object($src) and $self->_can($src, 'seek') and $self->_can($src, 'read')) { }
0 0 elsif (fileno $src) { }
691 0 0 unless $src->seek(0, 0)
701 0 0 unless seek $src, 0, 0
734 12 1 if ref $_[-1] eq "HASH"
740 0 13 @_ >= 2 ? :
744 0 13 unless (defined $dec and length $dec and $size)
747 0 0 if @_ >= 2
752 0 13 unless exists $filters->{$dec}
756 0 13 if (@_ >= 2) { }
759 0 0 unless defined $rv
767 0 13 unless defined $rv
768 13 0 if defined $rv
785 12 0 if ref $_[-1] eq "HASH"
790 0 12 @_ >= 2 ? :
794 0 12 unless (defined $enc and length $enc and $size)
797 0 0 if @_ >= 2
802 0 12 unless exists $filters->{$enc}
806 0 12 if (@_ >= 2) { }
809 0 0 unless defined $rv
818 0 12 unless defined $rv
819 12 0 if defined $rv
830 0 0 if not defined $this or not $self->_is_array($this) and (ref $this and not overload::Method($this, "\"\""))
831 16 0 $self->_is_array($this) ? :
835 1 16 unless exists $HTTP::Promise::Stream::ENCODING_SUFFIX->{$_}
846 0 1 unless exists $HTTP::Promise::Stream::CLASSES->{$enc}
849 0 1 if exists $opts->{'version'} and length $opts->{'version'}
854 0 2 if $_ eq $decoder and $decoder eq $encoder
855 0 2 unless $self->_load_class($_, $p)
858 1 0 if $ok == 2
873 28 52 if ref $_[-1] eq "HASH"
874 80 0 unless exists $opts->{'binmode'} and length $opts->{'binmode'}
880 80 0 unless ($io)
884 12 68 if ($enc) { }
68 0 elsif ($dec) { }
888 0 12 unless exists $filters->{$enc}
891 0 12 unless defined $rv
899 0 68 unless exists $filters->{$dec}
902 1 67 unless defined $rv
909 0 0 if ($type eq 'scalar') { }
0 0 elsif ($type eq 'glob') { }
0 0 elsif (not ref $src) { }
933 4 75 if (ref $_[1] eq 'CODE') { }
61 14 elsif (&Scalar::Util::reftype($_[1]) eq 'SCALAR') { }
4 10 elsif (&Scalar::Util::reftype($_[1]) eq 'GLOB') { }
6 4 elsif ($self->_is_a($_[1], 'Module::Generic::File') or not ref $_[1] and length $_[1] and index($_[1], "\n") == -1) { }
938 0 4 if (@_ >= 3) { }
4 0 elsif (@_ >= 2) { }
941 0 0 unless defined $len
946 0 4 unless defined $len
955 0 4 if ($@)
962 0 61 if (@_ >= 4) { }
0 61 elsif (@_ >= 3) { }
61 0 elsif (@_ >= 2) { }
965 0 0 unless defined $len
970 0 0 unless defined $len
975 0 61 unless defined $len
983 0 4 if (@_ >= 3) { }
4 0 elsif (@_ >= 2) { }
986 0 0 unless defined $len
988 0 0 unless $rv
998 0 4 unless $rv
1000 0 4 unless defined $chunklen
1014 0 6 if (@_ >= 3) { }
6 0 elsif (@_ >= 2) { }
1017 0 0 unless defined $len
1022 0 6 unless defined $len
1024 0 6 $opts->{'mode'} ? :
1026 6 0 if $opts->{'binmode'}
1027 0 6 if $opts->{'autoflush'}
1028 0 6 unless $f->open($mode, $params)
1030 0 6 unless $f->print($buf)
1036 0 4 if (@_ >= 4) { }
0 4 elsif (@_ >= 3) { }
4 0 elsif (@_ >= 2) { }
1039 0 0 unless defined $len
1044 0 0 unless defined $len
1049 0 4 unless defined $len
1062 1 15 unless (defined $HTTP::Promise::Stream::SUFFIX_ENCODING and %$HTTP::Promise::Stream::SUFFIX_ENCODING)
1072 16 16 if (exists $HTTP::Promise::Stream::SUFFIX_ENCODING->{$_}) { }
1087 0 2 unless @_ and defined $_[0] and length $_[0]
1089 2 0 if exists $HTTP::Promise::Stream::FILTER_MAP->{'encode'}{$this} or exists $HTTP::Promise::Stream::FILTER_MAP->{'decode'}{$this}
1102 0 20 unless defined $_[1] and length $_[1]
1110 4 16 if ($type eq 'code') { }
1118 0 4 if ($@)
1132 4 12 if (not ref $_[1] and index($_[1], "\n") == -1 && !(-e $_[1]) || index($_[1], "\n") != -1) { }
4 8 elsif ($type eq 'scalar') { }
4 4 elsif ($self->_is_a($_[1], 'Module::Generic::File') or $self->_can($_[1], 'filename')) { }
1154 0 4 if ref $data and $type ne "scalar" and $type ne "glob" and $type ne "code"
1161 4 12 unless (ref $data)
1170 0 20 if ($stype eq 'code') { }
1172 0 0 if ($enc) { }
0 0 elsif ($dec) { }
1181 0 0 if ($@)
1196 0 0 if ($@)
1204 0 0 if ($type eq 'scalar') { }
0 0 elsif ($type eq 'glob') { }
1213 0 0 if ($@)
1229 0 0 if ($@)
1235 0 0 unless defined $rv
1243 0 0 unless defined $rv
1250 0 0 if ($@)
1262 0 20 if ($dec) { }
20 0 elsif ($enc) { }
1272 0 20 if ($dec) { }
20 0 elsif ($enc) { }
0 0 elsif ($stype eq 'scalar') { }
0 0 elsif ($stype eq 'glob') { }
1275 0 0 unless exists $filters->{$dec}
1282 0 0 if ($@)
1284 0 0 $self->encode ? :
1286 0 0 unless defined $rv
1292 0 20 unless exists $filters->{$enc}
1299 0 20 if ($@)
1301 0 0 $self->encode ? :
1303 0 20 unless defined $rv
1308 0 0 if ($type eq 'scalar') { }
0 0 elsif ($type eq 'glob') { }
1321 0 0 unless defined $rv
1330 0 0 unless defined $rv
1337 0 0 if ($type eq 'scalar') { }
0 0 elsif ($type eq 'glob') { }
1339 0 0 unless print $src, $$data
1348 0 0 unless print $src, $buf
1361 0 0 unless print $src, $buf
1371 0 0 if ($type eq 'scalar') { }
0 0 elsif ($type eq 'glob') { }
1373 0 0 unless $fh->print($$data)
1382 0 0 unless $fh->print($buf)
1395 0 0 unless $fh->print($buf)
1414 0 2 $enc_or_dec ? :
1415 0 2 if ($self->_is_array($what)) { }
0 2 elsif ($what eq 'all' or $what eq 'auto') { }
2 0 elsif ($what eq 'browser') { }
1427 18 28 if $HTTP::Promise::Stream::CLASSES->{$_}[2]
1439 6 10 if $enc eq "inflate" or $enc eq "rawinflate" or substr($enc, 0, 2) eq "x-"
1440 0 10 unless (exists $HTTP::Promise::Stream::CLASSES->{$enc})
1442 0 0 if $self->_is_warnings_enabled("HTTP::Promise")
1446 0 10 $enc_or_dec ? :
1447 0 10 if (my $coderef = $encoder_class->can($is_installed_method)) { }
10 0 elsif ($self->_is_class_loadable($encoder_class)) { }
1449 0 0 if &$coderef()
1462 87 34 if (ref $_[0]) { }
4 30 elsif (not ref $_[0] and index($_[0], "\n") == -1 && !(-e $_[0]) || index($_[0], "\n") != -1) { }
1465 71 16 if ($type eq 'scalar') { }
12 4 elsif ($type eq 'glob') { }
4 0 elsif ($self->_is_a($_[0], 'Module::Generic::File')) { }
1471 8 4 if ($self->_is_a($_[0], 'Module::Generic::Scalar::IO')) { }
0 4 elsif ($self->_is_object($_[0]) and $self->_can($_[0], 'size')) { }
4 0 elsif (fileno $_[0]) { }
1513 105 20 if (@_)
1517 9 96 if scalar @keys
1530 59 22 if (ref $_[0]) { }
1533 59 0 if ($type eq 'scalar') { }
0 0 elsif ($type eq 'glob') { }
0 0 elsif ($self->_is_a($_[0], 'Module::Generic::File') or $self->_can($_[0], 'filename')) { }
1537 39 20 if ($self->_is_object($_[0])) { }
1600 30 0 defined ${"${class}::EXCEPTION_CLASS";} ? :
1601 0 30 unless $self->SUPER::init(@_)
1609 0 23 unless defined $this and ref $this || length $this
1611 29 29 unless exists $opts->{'write'}
1612 29 29 $opts->{'write'} ? :
1615 3 55 if ($self->_is_glob($this)) { }
29 26 elsif ($self->_is_scalar($this)) { }
1619 3 0 if fileno $this
1630 0 22 unless $f->exists or $opts->{'write'}
1636 58 0 if ($self->_can($fh, 'fcntl')) { }
1645 58 0 if (defined $flags)
1647 29 29 if ($opts->{'write'}) { }
1649 0 29 unless ($flags & 1027)
1657 0 29 unless (($flags & 0) == 0 or $flags & 2)
1669 29 29 if ($opts->{'write'}) { }
1671 29 0 if ($is_native_glob) { }
0 0 elsif ($meth = $self->_can($fh, 'print') || $self->_can($fh, 'write')) { }
1676 0 357 unless defined $rv
1690 0 0 if ($@)
1694 0 0 unless (defined $rv)
1697 0 0 if (defined $!) { }
0 0 elsif ($self->_can($fh, 'error')) { }
0 0 elsif ($self->_can($fh, 'errstr')) { }
1721 29 0 if ($is_native_glob) { }
0 0 elsif ($self->_can($fh, 'read')) { }
1726 0 351 unless defined $n
1740 0 0 if ($@)
1744 0 0 unless (defined $n)
1747 0 0 if (defined $!) { }
0 0 elsif ($self->_can($fh, 'error')) { }
0 0 elsif ($self->_can($fh, 'errstr')) { }