Branch Coverage

blib/lib/BSON.pm
Criterion Covered Total %
branch 116 214 54.2


line true false branch
39 0 71 if defined $ver
40 70 71 unless $load
41 70 71 unless $load
47 1 70 if ($class = $ENV{'PERL_BSON_BACKEND'}) { }
0 70 elsif (eval { do { _try_load($class = 'BSON::XS') } } or do { push @errs, $@; 0 }) { }
70 0 elsif (eval { do { _try_load($class = 'BSON::PP') } } or do { push @errs, $@; 0 }) { }
49 0 1 if (my $err = $@)
53 0 1 unless ($class->can('_encode_bson') and $class->can('_decode_bson'))
258 763 0 unless defined $self->{'wrap_dbrefs'}
259 761 2 unless defined $self->{'invalid_chars'}
294 1 2493 unless $type
296 2 2491 if ($type eq 'Regexp' or not &blessed($document) || $type eq 'HASH' || $type eq 'ARRAY')
302 1 2490 if $type eq 'ARRAY'
305 739 1752 $options ? :
310 12 2479 if ($@ or $merged_opts->{'max_length'} and length $bson > $merged_opts->{'max_length'})
312 0 12 if ($merged_opts->{'error_callback'}) { }
347 698 1461 $options ? :
349 1 2158 if ($merged_opts->{'max_length'} and length $string > $merged_opts->{'max_length'})
351 0 1 if ($merged_opts->{'error_callback'}) { }
360 79 2079 if ($@)
361 1 78 if ($merged_opts->{'error_callback'}) { }
384 0 0 if (@args == 1 and ref $args[0] eq 'HASH')
423 0 0 if (substr($k, 0, 1) eq '$')
427 0 0 $v ? :
0 0 $type =~ /$bools_re/ ? :
0 0 $type eq 'ARRAY' ? :
0 0 $type eq 'HASH' ? :
469 6 3661 unless (defined $data)
473 1766 1895 if (&blessed($data) and $data->can('TO_JSON'))
478 67 1828 unless (ref $data)
480 25 42 if (&looks_like_number($data))
481 16 9 if ($ENV{'BSON_EXTJSON_RELAXED'})
485 9 0 if ($data =~ /\A-?[0-9_]+\z/) { }
486 9 0 if ($data <= $max_int32) { }
494 0 0 if $data =~ /$is_inf/
496 0 0 if $data =~ /$is_ninf/
498 0 0 if $data =~ /$is_nan/
509 0 1828 if (&boolean::isBoolean($data))
513 1812 16 if (ref $data eq 'HASH')
521 10 6 if (ref $data eq 'ARRAY')
529 4 2 if (&blessed($data) and $data->isa('JSON::PP::Boolean'))
533 2 0 if (&blessed($data) and $data->isa('Math::BigInt') || $data->isa('Math::BigFloat'))
577 2101 76 if (ref $data eq 'HASH')
579 26 2075 if (exists $data->{'$oid'})
583 38 2037 if (exists $data->{'$numberInt'})
587 27 2010 if (exists $data->{'$numberLong'})
596 24 1986 if (exists $data->{'$binary'})
598 0 24 if (exists $data->{'$type'}) { }
613 17 1969 if (exists $data->{'$date'})
615 15 2 ref $v eq 'HASH' ? :
619 4 1965 if (exists $data->{'$minKey'})
623 4 1961 if (exists $data->{'$maxKey'})
627 10 1951 if (exists $data->{'$timestamp'})
634 0 1951 if (exists $data->{'$regex'} and not ref $data->{'$regex'})
637 0 0 exists $data->{'$options'} ? :
641 24 1927 if (exists $data->{'$regularExpression'})
645 24 0 exists $value->{'options'} ? :
649 20 1907 if (exists $data->{'$code'})
653 12 8 exists $data->{'$scope'} ? :
659 2 1905 if (exists $data->{'$undefined'})
663 8 1897 if (exists $data->{'$dbPointer'})
666 8 0 if ref $id eq 'HASH'
673 10 1887 if (exists $data->{'$ref'})
675 10 0 if ref $id eq 'HASH'
684 1823 64 if (exists $data->{'$numberDecimal'})
690 28 36 if (exists $data->{'$numberDouble'})
691 0 0 if ($data->{'$numberDouble'} eq '-0' and $] lt '5.014' and 1)
697 12 24 if (exists $data->{'$symbol'})
708 10 66 if (ref $data eq 'ARRAY')
711 16 0 ref $value ? :
747 0 740 if (defined $_[0] and $_[0] eq 'BSON' || &blessed($_[0]) && $_[0]->isa('BSON'))
751 20 720 unless defined $CODEC
752 101 639 if (@_ == 1 and ref $_[0] eq 'HASH') { }
639 0 elsif (@_ % 2 == 0) { }
764 0 698 if (defined $_[0] and $_[0] eq 'BSON' || &blessed($_[0]) && $_[0]->isa('BSON'))
768 18 680 unless defined $CODEC
770 0 698 if (@_ == 1 and ref $_[0] eq 'HASH') { }
698 0 elsif (@_ % 2 == 0) { }
780 1 697 if exists $args->{'ixhash'} and not exists $args->{'ordered'}
792 0 0 if (exists $hash->{'$oid'})
796 0 0 if (exists $hash->{'$numberInt'})
800 0 0 if (exists $hash->{'$numberLong'})
809 0 0 if (exists $hash->{'$binary'})
817 0 0 if (exists $hash->{'$date'})
819 0 0 ref $v eq 'HASH' ? :
823 0 0 if (exists $hash->{'$minKey'})
827 0 0 if (exists $hash->{'$maxKey'})
831 0 0 if (exists $hash->{'$timestamp'})
838 0 0 if (exists $hash->{'$regex'})
841 0 0 exists $hash->{'$options'} ? :
845 0 0 if (exists $hash->{'$code'})
848 0 0 exists $hash->{'$scope'} ? :
852 0 0 if (exists $hash->{'$undefined'})
856 0 0 if (exists $hash->{'$ref'})
858 0 0 if ref $id eq 'HASH'
862 0 0 if (exists $hash->{'$numberDecimal'})
868 0 0 if (exists $hash->{'$numberDouble'})
869 0 0 if ($hash->{'$numberDouble'} eq '-0' and $] lt '5.014' and 1)
875 0 0 if (exists $hash->{'$symbol'})
884 0 0 if (@$array)
887 0 0 ref $v eq 'ARRAY' ? :
0 0 ref $v eq 'HASH' ? :
907 2 0 if (substr($date, -1, 1) eq 'Z')
911 2 0 if ($date =~ /\A$iso8601_re\z/) { }
913 0 2 if (defined $z and length $z)
915 0 0 if length $z < 5
919 0 0 $zd eq '-' ? :