lib/Archive/Lha/Decode/Base.pm

filter: Statementstmt 98.3% 60 / 61 Branchbran 100% 2 / 2 Conditioncond 47.3% 9 / 19 MC/DCmcdc 9.0% 1 / 11 Subroutinesub 90.9% 10 / 11 Podpod 100% 1 / 1 totaltotal 79.0% 83 / 105 CC 11 SCAR 15.7
CC
11
Cov
87%
import
9.4
__ANON__
2.1
new
2.0
CRAP 4.8
« lib/Archive/Lha/Header/Base.pm ↑ Summary lib/Archive/Lha/Header/Level1.pm »
1 package Archive::Lha::Decode::Base;
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 18 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 18 ▶use Archive::Lha::Constants;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 18 ▶use Archive::Lha; # to load XS
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 18 my %_params; # keyed by subclass package name
10  
11 18 my @_PARAM_NAMES = qw(
12 NPT
13 NP
14 NT
15 NC
16 PBIT
17 TBIT
18 CBIT
19 PT_TABLE_BIT
20 PT_TABLE_SIZE
21 C_TABLE_BIT
22 C_TABLE_SIZE
23 DICSIZE
24 MAXMATCH
25 THRESHOLD
26 );
27  
28 # Install class methods for each param, looking up via %_params
29 18 for my $name (@_PARAM_NAMES) {
30 18 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
31 266 ▶ *{"Archive::Lha::Decode::Base::$name"} = sub { $_params{ ref($_[0]) || $_[0] }{$name} };
Subroutine __ANON__: called CC=2 SCAR=7.6
Condition33%1/3
ref $_[0] || $_[0]
l!l&&r!l&&!r
02660
MC/DC0%0/2
ref $_[0] || $_[0]
ref $_[0] $_[0]
Truth table33%1/3
A || B
A= ref $_[0]B= $_[0]
ABresult
1X1
011
000
32 }
33  
34 9 ▶sub import {
Subroutine import: called CC=9 SCAR=22.4
35 9 my ($class, %options) = @_;
36 9 my $caller = caller;
37  
38 9 ▶ my $dicbit = $options{dicbit} || 13;
Condition100%2/2
$options{'dicbit'} || 13
l!l
54
MC/DC100%1/1
$options{'dicbit'} || 13
$options{'dicbit'}
Truth table100%2/2
A
A= $options{'dicbit'}
Aresult
11
00
39 9 ▶ my $max_match = $options{max_match} || ( 1 << UCHAR_BIT );
Condition33%1/3
$options{'max_match'} || 1 << &UCHAR_BIT()
l!l&&r!l&&!r
090
MC/DC0%0/2
$options{'max_match'} || 1 << &UCHAR_BIT()
$options{'max_match'} 1 << &UCHAR_BIT()
Truth table33%1/3
A || B
A= $options{'max_match'}B= 1 << &UCHAR_BIT()
ABresult
1X1
011
000
40 9 ▶ my $threshold = $options{threshold} || 3;
Condition50%1/2
$options{'threshold'} || 3
l!l
09
MC/DC0%0/1
$options{'threshold'} || 3
$options{'threshold'}
Truth table50%1/2
A
A= $options{'threshold'}
Aresult
11
00
41 9 ▶ my $np = $options{np} || $dicbit + 1;
Condition33%1/3
$options{'np'} || $dicbit + 1
l!l&&r!l&&!r
090
MC/DC0%0/2
$options{'np'} || $dicbit + 1
$options{'np'} $dicbit + 1
Truth table33%1/3
A || B
A= $options{'np'}B= $dicbit + 1
ABresult
1X1
011
000
42 9 my $pbit = _bit_length( $np );
43 9 ▶ my $pt_table_bit = $options{pt_table_bit} || 8;
Condition50%1/2
$options{'pt_table_bit'} || 8
l!l
09
MC/DC0%0/1
$options{'pt_table_bit'} || 8
$options{'pt_table_bit'}
Truth table50%1/2
A
A= $options{'pt_table_bit'}
Aresult
11
00
44 9 ▶ my $c_table_bit = $options{c_table_bit} || 12;
Condition50%1/2
$options{'c_table_bit'} || 12
l!l
09
MC/DC0%0/1
$options{'c_table_bit'} || 12
$options{'c_table_bit'}
Truth table50%1/2
A
A= $options{'c_table_bit'}
Aresult
11
00
45 9 my $pt_table_size = 1 << $pt_table_bit;
46 9 my $c_table_size = 1 << $c_table_bit;
47 9 my $npt = $pt_table_size >> 1;
48 9 my $nt = USHORT_BIT + 3;
49 9 my $nc = UCHAR_MAX + $max_match + 2 - $threshold;
50 9 my $tbit = _bit_length( $nt );
51 9 my $cbit = _bit_length( $nc );
52  
53 9 $_params{$caller} = {
54 NPT => $npt,
55 NP => $np,
56 NT => $nt,
57 NC => $nc,
58 PBIT => $pbit,
59 TBIT => $tbit,
60 CBIT => $cbit,
61 PT_TABLE_BIT => $pt_table_bit,
62 PT_TABLE_SIZE => $pt_table_size,
63 C_TABLE_BIT => $c_table_bit,
64 C_TABLE_SIZE => $c_table_size,
65 DICSIZE => 1 << $dicbit,
66 MAXMATCH => $max_match,
67 THRESHOLD => $threshold,
68 };
69  
70 {
71 18 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
72 9 ▶ unless ( ${"$class\::_accessors_installed"} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (${"${class}::_accessors_installed";}) 5 4 9
73 5 ${"$class\::_accessors_installed"} = 1;
74 5 for my $name ( qw( pt c tree bit ) ) {
75 0 ▶ *{"$class\::$name"} = sub { shift->{$name} };
Subroutine __ANON__: not called CC=1 SCAR=0.4
76 }
77 }
78 9 push @{"$caller\::ISA"}, $class;
79 }
80 }
81  
82 19 ▶sub new {
Subroutine new: called CC=2 SCAR=7.0
Pod documented
83 19 my ($class, %options) = @_;
84  
85 19 my $header = $options{header};
86  
87 my $self = bless {
88 blocksize => 0,
89 read => $options{read},
90 write => $options{write},
91 encoded_size => $header->{encoded_size},
92 original_size => $header->{original_size},
93 crc16 => $header->{crc16} || 0,
94 19 ▶ map { $_ => $class->$_() } @_PARAM_NAMES,
Condition50%1/2
$header->{'crc16'} || 0
l!l
190
MC/DC0%0/1
$header->{'crc16'} || 0
$header->{'crc16'}
Truth table50%1/2
A
A= $header->{'crc16'}
Aresult
11
00
95 }, $class;
96  
97 19 $self;
98 }
99  
100 18 1;
101  
102 __END__
« lib/Archive/Lha/Header/Base.pm ↑ Summary lib/Archive/Lha/Header/Level1.pm »