| 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
| |||||||||||||
| 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
| |||||||||||||
| 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
| |||||||||||||
| 38 | } | ||||||||||||
| 39 | } | ||||||||||||
| 40 | 3 | } | |||||||||||
| 41 | 3 | shift; | |||||||||||
| 42 | 3 | ▶ | my $constants = shift || return; | ||||||||||
|
Condition100%2/2
shift() || (return)
MC/DC100%1/1
shift() || (return)
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||
| 43 | 2 | ▶ | $constants = { $constants => shift } unless ref($constants) eq 'HASH'; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 44 | 2 | $registered->{$caller}->{$_} = $constants->{$_} foreach keys %$constants; | |||||||||||
| 45 | } | ||||||||||||
| 46 | |||||||||||||
| 47 | 1 | 1; | |||||||||||
| 48 | |||||||||||||
| 49 | __END__ | ||||||||||||