lib/Games/Checkers/DeclareConstant.pm

filter: Statementstmt 12.5% 31 / 247 Branchbran 75.0% 6 / 8 Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 3.5% 8 / 224 Podpod n/a totaltotal 9.9% 48 / 482 CC 7 SCAR 9.2
CC
7
Cov
15%
import
22.4
__ANON__
10.7
__ANON__
2.0
CRAP 2.5
« lib/Games/Checkers/Constants.pm ↑ Summary blib/lib/Games/Checkers/Board/_10x10.pm »
1 # Games::Checkers, Copyright (C) 1996-2012 Mikhael Goikhman, migo@cpan.org
2 #
3 # This program is free software: you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation, either version 3 of the License, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
15  
16 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 package Games::Checkers::DeclareConstant;
20  
21 ## This is a general purpose module, kind of the next level of "use constant;".
22  
23 # keys are package names, values are hash of constants for the package
24 1 ▶use vars qw($registered);
Subroutine BEGIN: called CC=1 SCAR=0.0
25 1 $registered = {};
26  
27 3 ▶sub import ($;$$) {
Subroutine import: called CC=5 SCAR=31.1
28 3 my $caller = caller;
29 3 ▶ unless (exists $registered->{$caller}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $Games::Checkers::DeclareConstant::registered->{$caller}) 3 0 3
30 1 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
31 3 $registered->{$caller} = {};
32 3 ▶ *{"${caller}::import"} = sub ($) {
Subroutine __ANON__: called CC=3 SCAR=23.7
33 22 my $caller2 = caller;
34 22 ▶ while (my ($name, $value) = each %{$registered->{$caller}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$$Games::Checkers::DeclareConstant::registered{$caller};}) 218 22 240
35 218 local $^W = 0; # 5.005 still produces redefined warnings...
36 0 ▶ eval "*${caller2}::$name = sub () { \$value }";
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
Subroutine __ANON__: not called CC=1 SCAR=6.7
37 218 ▶ die $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 218 218
38 }
39 }
40 3 }
41 3 shift;
42 3 ▶ my $constants = shift || return;
Condition100%2/2
shift() || (return)
l!l
21
MC/DC100%1/1
shift() || (return)
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
43 2 ▶ $constants = { $constants => shift } unless ref($constants) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $constants eq "HASH" 1 1 2
44 2 $registered->{$caller}->{$_} = $constants->{$_} foreach keys %$constants;
45 }
46  
47 1 1;
48  
49 __END__
« lib/Games/Checkers/Constants.pm ↑ Summary blib/lib/Games/Checkers/Board/_10x10.pm »