| 1 | package Bifcode::V1; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 7 | ▶ | use 5.010; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 7 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 7 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 6 | ▶ | use boolean (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 6 | ▶ | use Carp (qw/croak shortmess/); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 6 | ▶ | use Exporter::Tidy all => [ | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | qw( encode_bifcode | ||||||||||||||||||||||||||||||||||||||||||
| 9 | decode_bifcode | ||||||||||||||||||||||||||||||||||||||||||
| 10 | force_bifcode | ||||||||||||||||||||||||||||||||||||||||||
| 11 | diff_bifcode) | ||||||||||||||||||||||||||||||||||||||||||
| 12 | 6 | ]; | |||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | # ABSTRACT: Serialisation similar to Bencode + undef/UTF8 | ||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | 5 | our $VERSION = 'v2.0.16'; | |||||||||||||||||||||||||||||||||||||||||
| 17 | 5 | our $max_depth; | |||||||||||||||||||||||||||||||||||||||||
| 18 | 5 | our @CARP_NOT = (__PACKAGE__); | |||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | 73 | ▶ | sub _croak { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_croak: called CC=5 SCAR=19.7
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | 73 | ▶ | my $type = shift // croak 'usage: _error($TYPE, [$msg])'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() // croak("usage: _error(\$TYPE, [\$msg])")
MC/DC0%0/1
shift() // croak("usage: _error(\$TYPE, [\$msg])")
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 73 | my %messages = ( | |||||||||||||||||||||||||||||||||||||||||
| 23 | Decode => 'garbage at', | ||||||||||||||||||||||||||||||||||||||||||
| 24 | DecodeBytes => 'malformed BYTES length at', | ||||||||||||||||||||||||||||||||||||||||||
| 25 | DecodeBytesTrunc => 'unexpected BYTES end of data at', | ||||||||||||||||||||||||||||||||||||||||||
| 26 | DecodeBytesTerm => 'missing BYTES termination at', | ||||||||||||||||||||||||||||||||||||||||||
| 27 | DecodeDepth => 'nesting depth exceeded at', | ||||||||||||||||||||||||||||||||||||||||||
| 28 | DecodeTrunc => 'unexpected end of data at', | ||||||||||||||||||||||||||||||||||||||||||
| 29 | DecodeFloat => 'malformed FLOAT data at', | ||||||||||||||||||||||||||||||||||||||||||
| 30 | DecodeFloatTrunc => 'unexpected FLOAT end of data at', | ||||||||||||||||||||||||||||||||||||||||||
| 31 | DecodeInteger => 'malformed INTEGER data at', | ||||||||||||||||||||||||||||||||||||||||||
| 32 | DecodeIntegerTrunc => 'unexpected INTEGER end of data at', | ||||||||||||||||||||||||||||||||||||||||||
| 33 | DecodeTrailing => 'trailing garbage at', | ||||||||||||||||||||||||||||||||||||||||||
| 34 | DecodeUTF8 => 'malformed UTF8 string length at', | ||||||||||||||||||||||||||||||||||||||||||
| 35 | DecodeUTF8Trunc => 'unexpected UTF8 end of data at', | ||||||||||||||||||||||||||||||||||||||||||
| 36 | DecodeUTF8Term => 'missing UTF8 termination at', | ||||||||||||||||||||||||||||||||||||||||||
| 37 | DecodeUsage => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 38 | DiffUsage => 'usage: diff_bifcode($b1, $b2, [$diff_args])', | ||||||||||||||||||||||||||||||||||||||||||
| 39 | EncodeBytesUndef => 'Bifcode::BYTES ref is undefined', | ||||||||||||||||||||||||||||||||||||||||||
| 40 | EncodeFloat => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 41 | EncodeFloatUndef => 'Bifcode::FLOAT ref is undefined', | ||||||||||||||||||||||||||||||||||||||||||
| 42 | EncodeInteger => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 43 | EncodeIntegerUndef => 'Bifcode::INTEGER ref is undefined', | ||||||||||||||||||||||||||||||||||||||||||
| 44 | DecodeKeyType => 'dict key is not BYTES or UTF8 at', | ||||||||||||||||||||||||||||||||||||||||||
| 45 | DecodeKeyDuplicate => 'duplicate dict key at', | ||||||||||||||||||||||||||||||||||||||||||
| 46 | DecodeKeyOrder => 'dict key not in sort order at', | ||||||||||||||||||||||||||||||||||||||||||
| 47 | DecodeKeyValue => 'dict key is missing value at', | ||||||||||||||||||||||||||||||||||||||||||
| 48 | EncodeUTF8Undef => 'Bifcode::UTF8 ref is undefined', | ||||||||||||||||||||||||||||||||||||||||||
| 49 | EncodeUnhandled => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 50 | EncodeUsage => 'usage: encode_bifcode($arg)', | ||||||||||||||||||||||||||||||||||||||||||
| 51 | ForceUsage => 'ref and type must be defined', | ||||||||||||||||||||||||||||||||||||||||||
| 52 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | 73 | my $err = 'Bifcode::Error::' . $type; | |||||||||||||||||||||||||||||||||||||||||
| 55 | 73 | ▶ | my $msg = shift // $messages{$type} // '(no message)'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition60%3/5
(shift() // $messages{$type}) // "(no message)"
shift() // $messages{$type}
MC/DC0%0/2
(shift() // $messages{$type}) // "(no message)"
shift()
$messages{$type}
Truth table66%2/3
A // B
A= shift()B= $messages{$type}
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | 73 | my $short = shortmess(''); | |||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | 73 | ▶ | $msg =~ s! at$!' at input byte '. ( pos() // 0 )!e; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
pos $_ // 0
MC/DC100%1/1
pos $_ // 0
pos $_
Truth table100%2/2
A
A= pos $_
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | eval 'package ' . $err . qq[; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=1.3
Subroutine
__ANON__: called CC=1 SCAR=1.3
Subroutine
__ANON__: called CC=1 SCAR=1.3
Subroutine
BEGIN: called CC=1 SCAR=1.3
Subroutine
BEGIN: called CC=1 SCAR=1.3
Subroutine
BEGIN: called CC=1 SCAR=1.3
Subroutine
BEGIN: called CC=1 SCAR=1.3
Subroutine
BEGIN: called CC=1 SCAR=1.3
Subroutine
BEGIN: called CC=1 SCAR=1.3
Subroutine
BEGIN: called CC=1 SCAR=1.3
Subroutine
BEGIN: called CC=1 SCAR=1.3
Subroutine
BEGIN: called CC=1 SCAR=1.3
Subroutine
BEGIN: called CC=1 SCAR=1.3
Subroutine
BEGIN: called CC=1 SCAR=1.3
Subroutine
BEGIN: called CC=1 SCAR=1.3
Subroutine
BEGIN: called CC=1 SCAR=1.3
Subroutine
BEGIN: called CC=1 SCAR=1.3
Subroutine
BEGIN: called CC=1 SCAR=1.3
Subroutine
BEGIN: called CC=1 SCAR=1.3
Subroutine
BEGIN: called CC=1 SCAR=1.3
Subroutine
BEGIN: called CC=1 SCAR=1.3
Subroutine
BEGIN: called CC=1 SCAR=1.3
Subroutine
BEGIN: called CC=1 SCAR=1.3
Subroutine
BEGIN: called CC=1 SCAR=1.3
Subroutine
BEGIN: called CC=1 SCAR=1.3
Subroutine
BEGIN: called CC=1 SCAR=1.3
Subroutine
BEGIN: called CC=1 SCAR=1.3
Subroutine
BEGIN: called CC=1 SCAR=1.3
Subroutine
BEGIN: called CC=1 SCAR=1.3
Subroutine
BEGIN: called CC=1 SCAR=1.3
Subroutine
BEGIN: called CC=1 SCAR=1.3
Subroutine
BEGIN: called CC=1 SCAR=1.3
Subroutine
BEGIN: called CC=1 SCAR=1.3
Subroutine
BEGIN: called CC=1 SCAR=1.3
Subroutine
BEGIN: called CC=1 SCAR=1.3
Subroutine
BEGIN: called CC=1 SCAR=1.3
Subroutine
BEGIN: called CC=1 SCAR=1.3
Subroutine
BEGIN: called CC=1 SCAR=1.3
Subroutine
BEGIN: called CC=1 SCAR=1.3
Subroutine
BEGIN: called CC=1 SCAR=1.3
Subroutine
BEGIN: called CC=1 SCAR=1.3
Subroutine
BEGIN: not called CC=1 SCAR=1.3
Subroutine
BEGIN: not called CC=1 SCAR=1.3
Subroutine
BEGIN: not called CC=1 SCAR=1.3
Subroutine
BEGIN: not called CC=1 SCAR=1.3
Subroutine
BEGIN: not called CC=1 SCAR=1.3
Subroutine
BEGIN: not called CC=1 SCAR=1.3
Subroutine
BEGIN: not called CC=1 SCAR=1.3
Subroutine
BEGIN: not called CC=1 SCAR=1.3
Subroutine
BEGIN: not called CC=1 SCAR=1.3
Subroutine
BEGIN: not called CC=1 SCAR=1.3
Subroutine
BEGIN: not called CC=1 SCAR=1.3
Subroutine
BEGIN: not called CC=1 SCAR=1.3
Subroutine
BEGIN: not called CC=1 SCAR=1.3
Subroutine
BEGIN: not called CC=1 SCAR=1.3
Subroutine
BEGIN: not called CC=1 SCAR=1.3
Subroutine
BEGIN: not called CC=1 SCAR=1.3
Subroutine
BEGIN: not called CC=1 SCAR=1.3
Subroutine
__ANON__: not called CC=1 SCAR=1.3
Subroutine
__ANON__: not called CC=1 SCAR=1.3
Subroutine
__ANON__: not called CC=1 SCAR=1.3
Subroutine
__ANON__: not called CC=1 SCAR=1.3
Subroutine
__ANON__: not called CC=1 SCAR=1.3
Subroutine
__ANON__: not called CC=1 SCAR=1.3
Subroutine
__ANON__: not called CC=1 SCAR=1.3
Subroutine
__ANON__: not called CC=1 SCAR=1.3
Subroutine
__ANON__: not called CC=1 SCAR=1.3
Subroutine
__ANON__: not called CC=1 SCAR=1.3
Subroutine
__ANON__: not called CC=1 SCAR=1.3
Subroutine
__ANON__: not called CC=1 SCAR=1.3
Subroutine
__ANON__: not called CC=1 SCAR=1.3
Subroutine
__ANON__: not called CC=1 SCAR=1.3
Subroutine
__ANON__: not called CC=1 SCAR=1.3
Subroutine
__ANON__: not called CC=1 SCAR=1.3
Subroutine
__ANON__: not called CC=1 SCAR=1.3
Subroutine
__ANON__: not called CC=1 SCAR=1.3
Subroutine
__ANON__: not called CC=1 SCAR=1.3
Subroutine
__ANON__: not called CC=1 SCAR=1.3
Subroutine
__ANON__: not called CC=1 SCAR=1.3
Subroutine
__ANON__: not called CC=1 SCAR=1.3
Subroutine
__ANON__: not called CC=1 SCAR=1.3
Subroutine
__ANON__: not called CC=1 SCAR=1.3
Subroutine
__ANON__: not called CC=1 SCAR=1.3
Subroutine
__ANON__: not called CC=1 SCAR=1.3
Subroutine
__ANON__: not called CC=1 SCAR=1.3
Subroutine
__ANON__: not called CC=1 SCAR=1.3
Subroutine
__ANON__: not called CC=1 SCAR=1.3
Subroutine
__ANON__: not called CC=1 SCAR=1.3
Subroutine
__ANON__: not called CC=1 SCAR=1.3
Subroutine
__ANON__: not called CC=1 SCAR=1.3
Subroutine
__ANON__: not called CC=1 SCAR=1.3
Subroutine
__ANON__: not called CC=1 SCAR=1.3
Subroutine
__ANON__: not called CC=1 SCAR=1.3
Subroutine
__ANON__: not called CC=1 SCAR=1.3
Subroutine
__ANON__: not called CC=1 SCAR=1.3
Subroutine
__ANON__: not called CC=1 SCAR=1.3
Subroutine
__ANON__: not called CC=1 SCAR=1.3
Subroutine
__ANON__: not called CC=1 SCAR=1.3
Subroutine
__ANON__: not called CC=1 SCAR=1.3
Subroutine
__ANON__: not called CC=1 SCAR=1.3
Subroutine
__ANON__: not called CC=1 SCAR=1.3
Subroutine
__ANON__: not called CC=1 SCAR=1.3
Subroutine
__ANON__: not called CC=1 SCAR=1.3
Subroutine
__ANON__: not called CC=1 SCAR=1.3
Subroutine
__ANON__: not called CC=1 SCAR=1.3
Subroutine
__ANON__: not called CC=1 SCAR=1.3
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | use overload | ||||||||||||||||||||||||||||||||||||||||||
| 62 | bool => sub { 1 }, | ||||||||||||||||||||||||||||||||||||||||||
| 63 | '""' => sub { \${ \$_[0] } . ' (' . ( ref \$_[0] ) . ')$short' }, | ||||||||||||||||||||||||||||||||||||||||||
| 64 | fallback => 1; | ||||||||||||||||||||||||||||||||||||||||||
| 65 | 1; ]; | ||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | 73 | die bless \$msg, $err; | |||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | 5 | my $match = qr/ \G (?| | |||||||||||||||||||||||||||||||||||||||||
| 71 | (~) | ||||||||||||||||||||||||||||||||||||||||||
| 72 | | (0) | ||||||||||||||||||||||||||||||||||||||||||
| 73 | | (1) | ||||||||||||||||||||||||||||||||||||||||||
| 74 | | (B|U) (?: ( 0 | [1-9] [0-9]* ) : )? | ||||||||||||||||||||||||||||||||||||||||||
| 75 | | (I) (?: ( 0 | -? [1-9] [0-9]* ) , )? | ||||||||||||||||||||||||||||||||||||||||||
| 76 | | (F) (?: ( 0 | -? [1-9] [0-9]* ) \. ( 0 | [0-9]* [1-9] ) e | ||||||||||||||||||||||||||||||||||||||||||
| 77 | ( (?: 0 | -? [1-9] ) [0-9]* ) , )? | ||||||||||||||||||||||||||||||||||||||||||
| 78 | | (\[) | ||||||||||||||||||||||||||||||||||||||||||
| 79 | | (\{) | ||||||||||||||||||||||||||||||||||||||||||
| 80 | ) /x; | ||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | 183 | ▶ | sub _decode_bifcode_chunk { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_decode_bifcode_chunk: called CC=38 SCAR=36.4
| |||||||||||||||||||||||||||||||||||||||||||
| 83 | 183 | ▶ | local $max_depth = $max_depth - 1 if defined $max_depth; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | 183 | ▶ | unless (m/$match/gc) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 86 | 6 | ▶ | _croak m/ \G \z /xgc ? 'DecodeTrunc' : 'Decode'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | 178 | ▶ | if ( $1 eq '~' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 9 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 90 | 9 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||
| 92 | elsif ( $1 eq '0' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 93 | 4 | return boolean::false; | |||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||
| 95 | elsif ( $1 eq '1' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 96 | 4 | return boolean::true; | |||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||
| 98 | elsif ( $1 eq 'B' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 99 | 8 | ▶ | my $len = $2 // _croak 'DecodeBytes'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$2 // _croak("DecodeBytes")
MC/DC0%0/2
$2 // _croak("DecodeBytes")
$2
_croak("DecodeBytes")
Truth table33%1/3
A // B
A= $2B= _croak("DecodeBytes")
| |||||||||||||||||||||||||||||||||||||||||||
| 100 | 6 | ▶ | _croak 'DecodeBytesTrunc' if $len > length() - pos(); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | 5 | my $data = substr $_, pos(), $len; | |||||||||||||||||||||||||||||||||||||||||
| 103 | 5 | pos() = pos() + $len; | |||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||
| 105 | 5 | ▶ | _croak 'DecodeBytesTerm' unless m/ \G , /xgc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 106 | 4 | return $data; | |||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||
| 108 | elsif ( $1 eq 'U' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 109 | 69 | ▶ | my $len = $2 // _croak 'DecodeUTF8'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$2 // _croak("DecodeUTF8")
MC/DC0%0/2
$2 // _croak("DecodeUTF8")
$2
_croak("DecodeUTF8")
Truth table33%1/3
A // B
A= $2B= _croak("DecodeUTF8")
| |||||||||||||||||||||||||||||||||||||||||||
| 110 | 64 | ▶ | _croak 'DecodeUTF8Trunc' if $len > length() - pos(); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | 62 | utf8::decode( my $str = substr $_, pos(), $len ); | |||||||||||||||||||||||||||||||||||||||||
| 113 | 62 | pos() = pos() + $len; | |||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | 62 | ▶ | _croak 'DecodeUTF8Term' unless m/ \G , /xgc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 116 | 60 | return $str; | |||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||
| 118 | elsif ( $1 eq 'I' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 119 | 25 | ▶ | return $2 if defined $2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 120 | 9 | ▶ | _croak 'DecodeIntegerTrunc' if m/ \G \z /xgc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 121 | 8 | _croak 'DecodeInteger'; | |||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||
| 123 | elsif ( $1 eq 'F' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 124 | 12 | ▶ | if ( !defined $2 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 125 | 9 | ▶ | _croak 'DecodeFloatTrunc' if m/ \G \z /xgc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 126 | 8 | _croak 'DecodeFloat'; | |||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||
| 128 | 4 | ▶ | _croak 'DecodeFloat' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$2 eq 0 and $3 eq 0 and $4 ne 0
$2 eq 0 and $3 eq 0
MC/DC66%2/3
$2 eq 0 and $3 eq 0 and $4 ne 0
$2 eq 0
$3 eq 0
$4 ne 0
Truth table75%3/4
A and B and C
A= $2 eq 0B= $3 eq 0C= $4 ne 0
| |||||||||||||||||||||||||||||||||||||||||||
| 129 | if $2 eq '0' # mantissa 0. | ||||||||||||||||||||||||||||||||||||||||||
| 130 | and $3 eq '0' # mantissa 0.0 | ||||||||||||||||||||||||||||||||||||||||||
| 131 | and $4 ne '0'; # sign or exponent 0.0e0 | ||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||
| 133 | 3 | return $2 . '.' . $3 . 'e' . $4; | |||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||
| 135 | elsif ( $1 eq '[' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 136 | 27 | ▶ | _croak 'DecodeDepth' if defined $max_depth and $max_depth < 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $Bifcode::V1::max_depth and $Bifcode::V1::max_depth < 0
MC/DC100%2/2
defined $Bifcode::V1::max_depth and $Bifcode::V1::max_depth < 0
defined $Bifcode::V1::max_depth
$Bifcode::V1::max_depth < 0
Truth table100%3/3
A and B
A= defined $Bifcode::V1::max_depthB= $Bifcode::V1::max_depth < 0
| |||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | 23 | my @list; | |||||||||||||||||||||||||||||||||||||||||
| 139 | 23 | ▶ | until (m/ \G \] /xgc) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 140 | 36 | push @list, _decode_bifcode_chunk(); | |||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||
| 142 | 17 | return \@list; | |||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||
| 144 | elsif ( $1 eq '{' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 145 | 28 | ▶ | _croak 'DecodeDepth' if defined $max_depth and $max_depth < 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $Bifcode::V1::max_depth and $Bifcode::V1::max_depth < 0
MC/DC100%2/2
defined $Bifcode::V1::max_depth and $Bifcode::V1::max_depth < 0
defined $Bifcode::V1::max_depth
$Bifcode::V1::max_depth < 0
Truth table100%3/3
A and B
A= defined $Bifcode::V1::max_depthB= $Bifcode::V1::max_depth < 0
| |||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||
| 147 | 25 | my $last_key; | |||||||||||||||||||||||||||||||||||||||||
| 148 | my %hash; | ||||||||||||||||||||||||||||||||||||||||||
| 149 | 25 | ▶ | until (m/ \G \} /xgc) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 150 | 34 | ▶ | _croak 'DecodeTrunc' if m/ \G \z /xgc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 151 | 32 | ▶ | _croak 'DecodeKeyType' unless m/ \G (B|U) /xgc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||
| 153 | 30 | pos() = pos() - 1; | |||||||||||||||||||||||||||||||||||||||||
| 154 | 30 | my $key = _decode_bifcode_chunk(); | |||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||
| 156 | 30 | ▶ | _croak 'DecodeKeyDuplicate' if exists $hash{$key}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 157 | 29 | ▶ | _croak 'DecodeKeyOrder' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $last_key and $key lt $last_key
MC/DC100%2/2
defined $last_key and $key lt $last_key
defined $last_key
$key lt $last_key
Truth table100%3/3
A and B
A= defined $last_keyB= $key lt $last_key
| |||||||||||||||||||||||||||||||||||||||||||
| 158 | if defined $last_key and $key lt $last_key; | ||||||||||||||||||||||||||||||||||||||||||
| 159 | 28 | ▶ | _croak 'DecodeKeyValue' if m/ \G \} /xgc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||
| 161 | 27 | $last_key = $key; | |||||||||||||||||||||||||||||||||||||||||
| 162 | 27 | $hash{$key} = _decode_bifcode_chunk(); | |||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||
| 164 | 14 | return \%hash; | |||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||
| 168 | 97 | ▶ | sub decode_bifcode { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
decode_bifcode: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 169 | 97 | local $_ = shift; | |||||||||||||||||||||||||||||||||||||||||
| 170 | 97 | local $max_depth = shift; | |||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||
| 172 | 97 | ▶ | _croak 'DecodeUsage', 'decode_bifcode: too many arguments' if @_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 173 | 96 | ▶ | _croak 'DecodeUsage', 'decode_bifcode: input undefined' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 174 | unless defined $_; | ||||||||||||||||||||||||||||||||||||||||||
| 175 | 94 | ▶ | _croak 'DecodeUsage', 'decode_bifcode: only accepts bytes' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 176 | if utf8::is_utf8($_); | ||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||
| 178 | 93 | my $deserialised_data = _decode_bifcode_chunk(); | |||||||||||||||||||||||||||||||||||||||||
| 179 | 44 | ▶ | _croak 'DecodeTrailing' if $_ !~ m/ \G \z /xgc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 180 | 40 | return $deserialised_data; | |||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||
| 183 | 5 | my $number_qr = qr/\A ( 0 | -? [1-9] [0-9]* ) | |||||||||||||||||||||||||||||||||||||||||
| 184 | ( \. ( [0-9]+? ) 0* )? | ||||||||||||||||||||||||||||||||||||||||||
| 185 | ( e ( -? [0-9]+ ) )? \z/xi; | ||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||
| 187 | 154 | ▶ | sub _encode_bifcode { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_encode_bifcode: called CC=24 SCAR=31.8
| |||||||||||||||||||||||||||||||||||||||||||
| 188 | map { | ||||||||||||||||||||||||||||||||||||||||||
| 189 | 154 | ▶ | if ( !defined $_ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 9 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 190 | 9 | '~'; | |||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||
| 192 | elsif ( ( my $ref = ref $_ ) eq '' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 193 | 93 | ▶ | if ( $_ =~ $number_qr ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 194 | 71 | ▶ | if ( defined $3 or defined $5 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $3 or defined $5
MC/DC100%2/2
defined $3 or defined $5
defined $3
defined $5
Truth table100%3/3
A or B
A= defined $3B= defined $5
| |||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||
| 196 | # normalize to BIFCODE_FLOAT standards | ||||||||||||||||||||||||||||||||||||||||||
| 197 | 51 | ▶ | my $x = 'F' . ( 0 + $1 ) # remove leading zeros | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%4/4
$3 // 0
$5 // 0
MC/DC100%1/1
$3 // 0
$3
MC/DC100%1/1
$5 // 0
$5
Truth table100%2/2
A
A= $3
Truth table100%2/2
A
A= $5
| |||||||||||||||||||||||||||||||||||||||||||
| 198 | . '.' . ( $3 // 0 ) . 'e' . ( 0 + ( $5 // 0 ) ) . ','; | ||||||||||||||||||||||||||||||||||||||||||
| 199 | 51 | $x =~ s/ ([1-9]) (0+ e)/.${1}e/x; # remove trailing zeros | |||||||||||||||||||||||||||||||||||||||||
| 200 | 51 | $x; | |||||||||||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||||||||||
| 202 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 203 | 21 | 'I' . $_ . ','; | |||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||
| 206 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 207 | 23 | utf8::encode( my $str = $_ ); | |||||||||||||||||||||||||||||||||||||||||
| 208 | 23 | 'U' . length($str) . ':' . $str . ','; | |||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||
| 211 | elsif ( $ref eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 212 | 11 | '[' . join( '', map _encode_bifcode($_), @$_ ) . ']'; | |||||||||||||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||||||||||||
| 214 | elsif ( $ref eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 215 | '{' . join( | ||||||||||||||||||||||||||||||||||||||||||
| 216 | '', | ||||||||||||||||||||||||||||||||||||||||||
| 217 | 13 | do { | |||||||||||||||||||||||||||||||||||||||||
| 218 | 13 | my @k = sort keys %$_; | |||||||||||||||||||||||||||||||||||||||||
| 219 | map { | ||||||||||||||||||||||||||||||||||||||||||
| 220 | 27 | my $k = shift @k; | |||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||
| 222 | # if ( is valid utf8($k) ) { | ||||||||||||||||||||||||||||||||||||||||||
| 223 | 27 | utf8::encode($k); | |||||||||||||||||||||||||||||||||||||||||
| 224 | 27 | ( 'U' . length($k) . ':' . $k . ',', $_ ); | |||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||
| 226 | # } | ||||||||||||||||||||||||||||||||||||||||||
| 227 | # else { | ||||||||||||||||||||||||||||||||||||||||||
| 228 | # ('B' . length($k) . ':' . $k .',', $_); | ||||||||||||||||||||||||||||||||||||||||||
| 229 | # } | ||||||||||||||||||||||||||||||||||||||||||
| 230 | 13 | } _encode_bifcode( @$_{@k} ); | |||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||
| 232 | ) . '}'; | ||||||||||||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||||||||||||
| 234 | ▶ | elsif ( $ref eq 'SCALAR' or $ref eq 'Bifcode::BYTES' ) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$ref eq "SCALAR" or $ref eq "Bifcode::BYTES"
MC/DC100%2/2
$ref eq "SCALAR" or $ref eq "Bifcode::BYTES"
$ref eq "SCALAR"
$ref eq "Bifcode::BYTES"
Truth table100%3/3
A or B
A= $ref eq "SCALAR"B= $ref eq "Bifcode::BYTES"
| |||||||||||||||||||||||||||||||||||||||||||
| 235 | 11 | ▶ | $$_ // _croak 'EncodeBytesUndef'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$$_ // _croak("EncodeBytesUndef")
MC/DC0%0/2
$$_ // _croak("EncodeBytesUndef")
$$_
_croak("EncodeBytesUndef")
Truth table66%2/3
A // B
A= $$_B= _croak("EncodeBytesUndef")
| |||||||||||||||||||||||||||||||||||||||||||
| 236 | 9 | 'B' . length($$_) . ':' . $$_ . ','; | |||||||||||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||||||||||||
| 238 | elsif ( boolean::isBoolean($_) ) { | ||||||||||||||||||||||||||||||||||||||||||
| 239 | 9 | $_; | |||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||
| 241 | elsif ( $ref eq 'Bifcode::INTEGER' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 242 | 6 | ▶ | $$_ // _croak 'EncodeIntegerUndef'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$$_ // _croak("EncodeIntegerUndef")
MC/DC0%0/2
$$_ // _croak("EncodeIntegerUndef")
$$_
_croak("EncodeIntegerUndef")
Truth table66%2/3
A // B
A= $$_B= _croak("EncodeIntegerUndef")
| |||||||||||||||||||||||||||||||||||||||||||
| 243 | 5 | ▶ | _croak 'EncodeInteger', 'invalid integer: ' . $$_ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 244 | unless $$_ =~ m/\A (?: 0 | -? [1-9] [0-9]* ) \z/x; | ||||||||||||||||||||||||||||||||||||||||||
| 245 | 3 | sprintf 'I%s,', $$_; | |||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||
| 247 | elsif ( $ref eq 'Bifcode::FLOAT' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 248 | 17 | ▶ | $$_ // _croak 'EncodeFloatUndef'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$$_ // _croak("EncodeFloatUndef")
MC/DC0%0/2
$$_ // _croak("EncodeFloatUndef")
$$_
_croak("EncodeFloatUndef")
Truth table66%2/3
A // B
A= $$_B= _croak("EncodeFloatUndef")
| |||||||||||||||||||||||||||||||||||||||||||
| 249 | 16 | ▶ | _croak 'EncodeFloat', 'invalid float: ' . $$_ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 250 | unless $$_ =~ $number_qr; | ||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||
| 252 | 15 | ▶ | my $x = 'F' . ( 0 + $1 ) # remove leading zeros | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%4/4
$3 // 0
$5 // 0
MC/DC100%1/1
$3 // 0
$3
MC/DC100%1/1
$5 // 0
$5
Truth table100%2/2
A
A= $3
Truth table100%2/2
A
A= $5
| |||||||||||||||||||||||||||||||||||||||||||
| 253 | . '.' . ( $3 // 0 ) . 'e' . ( 0 + ( $5 // 0 ) ) . ','; | ||||||||||||||||||||||||||||||||||||||||||
| 254 | 15 | $x =~ s/ ([1-9]) (0+ e)/.${1}e/x; # remove trailing zeros | |||||||||||||||||||||||||||||||||||||||||
| 255 | 15 | $x; | |||||||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||||||
| 257 | elsif ( $ref eq 'Bifcode::UTF8' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 258 | 6 | ▶ | my $str = $$_ // _croak 'EncodeUTF8Undef'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$$_ // _croak("EncodeUTF8Undef")
MC/DC0%0/2
$$_ // _croak("EncodeUTF8Undef")
$$_
_croak("EncodeUTF8Undef")
Truth table33%1/3
A // B
A= $$_B= _croak("EncodeUTF8Undef")
| |||||||||||||||||||||||||||||||||||||||||||
| 259 | 5 | utf8::encode($str); #, sub { croak 'invalid Bifcode::UTF8' } ); | |||||||||||||||||||||||||||||||||||||||||
| 260 | 5 | 'U' . length($str) . ':' . $str . ','; | |||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||
| 262 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 263 | 2 | _croak 'EncodeUnhandled', 'unhandled data type: ' . $ref; | |||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||
| 265 | } @_; | ||||||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||
| 268 | 125 | ▶ | sub encode_bifcode { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
encode_bifcode: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 269 | 125 | ▶ | _croak 'EncodeUsage' if @_ != 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 270 | 122 | (&_encode_bifcode)[0]; | |||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||
| 273 | 17 | ▶ | sub force_bifcode { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
force_bifcode: called CC=3 SCAR=12.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 274 | 17 | my $ref = shift; | |||||||||||||||||||||||||||||||||||||||||
| 275 | 17 | my $type = shift; | |||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||
| 277 | 17 | ▶ | _croak 'ForceUsage' unless defined $ref and defined $type; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $ref and defined $type
MC/DC0%0/2
defined $ref and defined $type
defined $ref
defined $type
Truth table33%1/3
A and B
A= defined $refB= defined $type
| |||||||||||||||||||||||||||||||||||||||||||
| 278 | 17 | bless \$ref, 'Bifcode::' . uc($type); | |||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||
| 281 | 11 | ▶ | sub _expand_bifcode { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_expand_bifcode: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 282 | 11 | my $bifcode = shift; | |||||||||||||||||||||||||||||||||||||||||
| 283 | 11 | $bifcode =~ s/ ( | |||||||||||||||||||||||||||||||||||||||||
| 284 | [~\[\]\{\}] | ||||||||||||||||||||||||||||||||||||||||||
| 285 | | (U|B) [0-9]+ : | ||||||||||||||||||||||||||||||||||||||||||
| 286 | | F -? [0-9]+ \. [0-9]+ e -? [0-9]+ , | ||||||||||||||||||||||||||||||||||||||||||
| 287 | | I [0-9]+ , | ||||||||||||||||||||||||||||||||||||||||||
| 288 | ) /\n$1/gmx; | ||||||||||||||||||||||||||||||||||||||||||
| 289 | 11 | $bifcode =~ s/ \A \n //mx; | |||||||||||||||||||||||||||||||||||||||||
| 290 | 11 | $bifcode . "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||
| 293 | 8 | ▶ | sub diff_bifcode { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
diff_bifcode: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 294 | 8 | ▶ | _croak 'DiffUsage' unless @_ >= 2 and @_ <= 3; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@_ >= 2 and @_ <= 3
MC/DC100%2/2
@_ >= 2 and @_ <= 3
@_ >= 2
@_ <= 3
Truth table100%3/3
A and B
A= @_ >= 2B= @_ <= 3
| |||||||||||||||||||||||||||||||||||||||||||
| 295 | 6 | my $b1 = shift; | |||||||||||||||||||||||||||||||||||||||||
| 296 | 6 | my $b2 = shift; | |||||||||||||||||||||||||||||||||||||||||
| 297 | 6 | ▶ | my $diff_args = shift || { STYLE => 'Unified' }; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() || {'STYLE', 'Unified'}
MC/DC0%0/1
shift() || {'STYLE', 'Unified'}
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||
| 299 | 6 | require Text::Diff; | |||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||
| 301 | 6 | $b1 = _expand_bifcode($b1); | |||||||||||||||||||||||||||||||||||||||||
| 302 | 6 | $b2 = _expand_bifcode($b2); | |||||||||||||||||||||||||||||||||||||||||
| 303 | 6 | return Text::Diff::diff( \$b1, \$b2, $diff_args ); | |||||||||||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||
| 306 | 5 | decode_bifcode('I1,'); | |||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||
| 308 | __END__ | ||||||||||||||||||||||||||||||||||||||||||