lib/Archive/Lha/Constants.pm

filter: Statementstmt 94.7% 36 / 38 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 75.0% 6 / 8 Podpod n/a totaltotal 91.6% 44 / 48 CC 4 SCAR 5.5
CC
4
Cov
95%
import
3.0
_bit_length
2.0
__ANON__
1.0
CRAP 1.7
« lib/Archive/Lha/Decode.pm ↑ Summary lib/Archive/Lha/Decode/LH0.pm »
1 package Archive::Lha::Constants;
2
3 18 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 18 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5
6 60 ▶sub import {
Subroutine import: called CC=3 SCAR=11.0
7 60 my $class = shift;
8 60 my $caller = caller;
9
10 60 my %size = ( CHAR => 1, UCHAR => 1, USHORT => 2 );
11 60 my %const;
12 60 foreach my $type ( keys %size ) {
13 180 $const{$type.'_SIZE'} = $size{$type};
14 180 $const{$type.'_BIT'} = $size{$type} * 8;
15 180 $const{$type.'_MAX'} = ( 1 << $size{$type} * 8 ) - 1;
16 }
17 60 $const{USHORT_CENTER} = int( ( $const{USHORT_MAX} + 1 ) / 2 );
18
19 {
20 18 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
21 60 foreach my $key ( keys %const ) {
22 600 ▶ *{"$caller\::$key"} = sub () { $const{$key} };
Subroutine __ANON__: called CC=1 SCAR=0.0
23 }
24 0 ▶ *{"$caller\::_ushort"} = sub { shift() & $const{USHORT_MAX} };
Subroutine __ANON__: not called CC=1 SCAR=0.4
25 0 ▶ *{"$caller\::_uchar"} = sub { shift() & $const{UCHAR_MAX} };
Subroutine __ANON__: not called CC=1 SCAR=0.4
26 60 *{"$caller\::_bit_length"} = \&_bit_length;
27 }
28 }
29
30 27 ▶sub _bit_length {
Subroutine _bit_length: called CC=2 SCAR=6.9
31 27 my $bits = shift;
32 27 my $length = 0;
33 27 ▶ while ( $bits ) { $bits >>= 1; $length++; }
Branch: 1 branch
BranchTrueFalseTotal
if ($bits) 165 27 192
34 27 return $length;
35 }
36
37 18 1;
38
39 __END__
« lib/Archive/Lha/Decode.pm ↑ Summary lib/Archive/Lha/Decode/LH0.pm »