web/cgi-bin/yatt.lib/YATT/Util/Enum.pm

filter: Statementstmt 93.1% 27 / 29 Branchbran 58.3% 7 / 12 Conditioncond 60.0% 6 / 10 MC/DCmcdc 33.3% 2 / 6 Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 75.4% 46 / 61 CC 12 SCAR 24.9
CC
12
Cov
78%
import
14.8
BEGIN
1.0
BEGIN
1.0
CRAP 12.0
« web/cgi-bin/yatt.lib/YATT/Exception.pm ↑ Summary web/cgi-bin/yatt.lib/YATT/Translator/Perl.pm »
1 # -*- mode: perl; coding: utf-8 -*-
2 package YATT::Util::Enum;
3 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 8 ▶use warnings qw(FATAL all NONFATAL misc);
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 8 ▶use YATT::Util::Symbol qw/define_const/;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 26 ▶sub import {
Subroutine import: called CC=12 SCAR=26.9
9 26 my ($pack) = shift;
10 26 my $callpack = caller;
11  
12 #----------------------------------------
13 26 my %opts;
14 26 ▶ for (; @_ and $_[0] =~ /^-(\w+)/; splice @_, 0, 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ and $_[0] =~ /^-(\w+)/) 19 26 45
Condition66%2/3
@_ and $_[0] =~ /^-(\w+)/
!ll&&!rl&&r
02619
MC/DC50%1/2
@_ and $_[0] =~ /^-(\w+)/
@_ $_[0] =~ /^-(\w+)/
Truth table66%2/3
A and B
A= @_B= $_[0] =~ /^-(\w+)/
ABresult
0X0
100
111
15 19 $opts{$1} = $_[1];
16 }
17 26 ▶ my $offset = delete $opts{offset} || 0;
Condition50%1/2
delete $opts{'offset'} || 0
l!l
026
MC/DC0%0/1
delete $opts{'offset'} || 0
delete $opts{'offset'}
Truth table50%1/2
A
A= delete $opts{'offset'}
Aresult
11
00
18 26 ▶ my $prefix = delete $opts{prefix} || "";
Condition100%2/2
delete $opts{'prefix'} || ''
l!l
197
MC/DC100%1/1
delete $opts{'prefix'} || ''
delete $opts{'prefix'}
Truth table100%2/2
A
A= delete $opts{'prefix'}
Aresult
11
00
19 my $export = delete $opts{export}
20 26 ▶ ? $callpack . "::EXPORT" : "";
Branch: 1 branch
BranchTrueFalseTotal
delete $opts{'export'} ? : 0 26 26
21 my $export_ok = $export || delete $opts{export_ok}
22 26 ▶ ? $callpack . "::EXPORT_OK" : "";
Branch: 1 branch
BranchTrueFalseTotal
$export || delete $opts{'export_ok'} ? : 0 26 26
Condition33%1/3
$export or delete $opts{"export_ok"}
l!l&&r!l&&!r
0026
MC/DC0%0/2
$export or delete $opts{"export_ok"}
$export delete $opts{"export_ok"}
Truth table33%1/3
A or B
A= $exportB= delete $opts{"export_ok"}
ABresult
1X1
011
000
23 26 ▶ die "Unknown options for " . __PACKAGE__ . "\n".
Branch: 1 branch
BranchTrueFalseTotal
if keys %opts 0 26 26
24 join ", ", keys %opts if keys %opts;
25  
26 #----------------------------------------
27 26 foreach my $item (@_) {
28 155 my $full_name = $callpack . "::" . $prefix . $item;
29 {
30 155 define_const($full_name, $offset);
31 0 ▶ push @{$export}, $full_name if $export;
Branch: 1 branch
BranchTrueFalseTotal
if $export 0 155 155
32 0 ▶ push @{$export_ok}, $full_name if $export_ok;
Branch: 1 branch
BranchTrueFalseTotal
if $export_ok 0 155 155
33 }
34 } continue {
35 155 $offset++;
36 }
37 }
38  
39 8 1;
« web/cgi-bin/yatt.lib/YATT/Exception.pm ↑ Summary web/cgi-bin/yatt.lib/YATT/Translator/Perl.pm »