lib/Chj/NamespaceClean.pm

filter: Statementstmt 100% 47 / 47 Branchbran 100% 6 / 6 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 9 / 9 Podpod 0.0% 0 / 2 totaltotal 94.2% 65 / 69 CC 7 SCAR 11.4
CC
7
Cov
98%
package_delete
6.0
package_keys
2.0
BEGIN
1.0
CRAP 3.1
« lib/FP/Array_sort.pm ↑ Summary lib/FP/PureArray.pm »
1 #
2 # Copyright (c) 2013-2015 Christian Jaeger, copying@christianjaeger.ch
3 #
4 # This is free software, offered under either the same terms as perl 5
5 # or the terms of the Artistic License version 2 or the terms of the
6 # MIT License (Expat version). See the file COPYING.md that came
7 # bundled with this file.
8 #
9  
10 =head1 NAME
11  
12 Chj::NamespaceClean
13  
14 =head1 SYNOPSIS
15  
16 =head1 DESCRIPTION
17  
18 =head1 TODO
19  
20 Reuse pieces of L<namespace::clean> or similar instead?
21  
22 =head1 SEE ALSO
23  
24 L<Chj::NamespaceCleanAbove>, L<FP::Struct>, L<namespace::clean>
25  
26 =head1 NOTE
27  
28 This is alpha software! Read the status section in the package README
29 or on the L<website|http://functional-perl.org/>.
30  
31 =cut
32  
33 package Chj::NamespaceClean;
34 61 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
35 61 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
36 61 ▶use warnings FATAL => 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
37 61 ▶use Exporter "import";
Subroutine BEGIN: called CC=1 SCAR=0.0
38  
39 61 our @EXPORT = qw(package_keys package_delete);
40 61 our @EXPORT_OK = qw();
41 61 our %EXPORT_TAGS = (all => [@EXPORT, @EXPORT_OK]);
42  
43 438 ▶sub package_keys {
Subroutine package_keys: called CC=2 SCAR=6.9
Pod undocumented
44 438 my ($package) = @_;
45 61 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
46 [
47 map {
48 12829 ▶ if (my $c = *{"${package}::$_"}{CODE}) { [$_, $c] }
Branch: 1 branch
BranchTrueFalseTotal
if (my $c = *{"${package}::$_";}{'CODE'}) { } 11667 1162 12829
49 1162 else { () }
50 438 } keys %{ $package . "::" }
51 ]
52 }
53  
54 61 my @slotnames = qw(SCALAR HASH ARRAY IO);
55  
56 424 ▶sub package_delete {
Subroutine package_delete: called CC=6 SCAR=17.9
Pod undocumented
57 424 my ($package, $keys) = @_;
58  
59 #warn "package_delete '$package'";
60 61 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
61 424 for (@$keys) {
62 11419 my ($key, $val) = @$_;
63 61 ▶ no warnings 'once';
Subroutine BEGIN: called CC=1 SCAR=0.0
64 11419 my $val2 = *{"${package}::$key"}{CODE};
65  
66 # check val to be equal so that it will work with Chj::ruse
67 11419 ▶ if ($val2 and $val == $val2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($val2 and $val == $val2) 11382 37 11419
Condition66%2/3
$val2 and $val == $val2
!ll&&!rl&&r
03711382
MC/DC50%1/2
$val2 and $val == $val2
$val2 $val == $val2
Truth table66%2/3
A and B
A= $val2B= $val == $val2
ABresult
0X0
100
111
68  
69 #warn "deleting ${package}::$key ($val)";
70 11382 my @v = map { *{"${package}::$key"}{$_} } @slotnames;
71 11382 delete ${ $package . "::" }{$key};
72 11382 for (@v) {
73 45528 ▶ *{"${package}::$key"} = $_ if defined $_
Branch: 1 branch
BranchTrueFalseTotal
if defined $_ 11382 34146 45528
74 }
75 }
76 }
77 }
78  
79 # sub package_wipe {
80 # my ($package) = @_;
81 # package_delete $package, package_keys $package
82 # }
83  
84 61 1
« lib/FP/Array_sort.pm ↑ Summary lib/FP/PureArray.pm »