blib/lib/Test2/Util/HashBase.pm

filter: Statementstmt 91.9% 91 / 99 Branchbran 88.2% 30 / 34 Conditioncond 68.4% 13 / 19 MC/DCmcdc 45.4% 5 / 11 Subroutinesub 87.5% 14 / 16 Podpod 100% 1 / 1 totaltotal 85.5% 154 / 180 CC 28 SCAR 20.6
CC
28
Cov
88%
import
15.1
_new
8.0
BEGIN
4.9
CRAP 7.9
« blib/lib/Test/More.pm ↑ Summary blib/lib/Test2/Workflow.pm »
1 package Test2::Util::HashBase;
2 455 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 455 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 455 our $VERSION = '1.302226';
6  
7 #################################################################
8 # #
9 # This is a generated file! Do not modify this file directly! #
10 # Use hashbase_inc.pl script to regenerate this file. #
11 # The script is part of the Object::HashBase distribution. #
12 # Note: You can modify the version number above this comment #
13 # if needed, that is fine. #
14 # #
15 #################################################################
16  
17 {
18 455 ▶ no warnings 'once';
Subroutine BEGIN: called CC=1 SCAR=0.0
19 455 $Test2::Util::HashBase::HB_VERSION = '0.009';
20 455 *Test2::Util::HashBase::ATTR_SUBS = \%Object::HashBase::ATTR_SUBS;
21 455 *Test2::Util::HashBase::ATTR_LIST = \%Object::HashBase::ATTR_LIST;
22 455 *Test2::Util::HashBase::VERSION = \%Object::HashBase::VERSION;
23 455 *Test2::Util::HashBase::CAN_CACHE = \%Object::HashBase::CAN_CACHE;
24 }
25  
26  
27 455 require Carp;
28 {
29 455 ▶ no warnings 'once';
Subroutine BEGIN: called CC=1 SCAR=0.0
30 455 $Carp::Internal{+__PACKAGE__} = 1;
31 }
32  
33 455 ▶BEGIN {
Subroutine BEGIN: called CC=3 SCAR=16.0
34 # these are not strictly equivalent, but for out use we don't care
35 # about order
36 0 ▶ *_isa = ($] >= 5.010 && require mro) ? \&mro::get_linear_isa : sub {
Subroutine __ANON__: not called CC=2 SCAR=11.6
37 455 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
38 0 my @packages = ($_[0]);
39 0 my %seen;
40 0 for my $package (@packages) {
41 0 push @packages, grep !$seen{$_}++, @{"$package\::ISA"};
42 }
43 0 return \@packages;
44 }
45 455 ▶}
Branch: 1 branch
BranchTrueFalseTotal
$] >= 5.01 && require mro ? : 455 0 455
Condition33%1/3
$] >= "5.01" and require mro
!ll&&!rl&&r
00455
MC/DC0%0/2
$] >= "5.01" and require mro
$] >= "5.01" require mro
Truth table33%1/3
A and B
A= $] >= "5.01"B= require mro
ABresult
0X0
100
111
46  
47 455 my %SPEC = (
48 '^' => {reader => 1, writer => 0, dep_writer => 1, read_only => 0, strip => 1},
49 '-' => {reader => 1, writer => 0, dep_writer => 0, read_only => 1, strip => 1},
50 '>' => {reader => 0, writer => 1, dep_writer => 0, read_only => 0, strip => 1},
51 '<' => {reader => 1, writer => 0, dep_writer => 0, read_only => 0, strip => 1},
52 '+' => {reader => 0, writer => 0, dep_writer => 0, read_only => 0, strip => 1},
53 );
54  
55 20689 ▶sub import {
Subroutine import: called CC=15 SCAR=27.1
56 20689 my $class = shift;
57 20689 my $into = caller;
58  
59 # Make sure we list the OLDEST version used to create this class.
60 20689 ▶ my $ver = $Test2::Util::HashBase::HB_VERSION || $Test2::Util::HashBase::VERSION;
Condition33%1/3
$Test2::Util::HashBase::HB_VERSION || $Test2::Util::HashBase::VERSION
l!l&&r!l&&!r
2068900
MC/DC0%0/2
$Test2::Util::HashBase::HB_VERSION || $Test2::Util::HashBase::VERSION
$Test2::Util::HashBase::HB_VERSION $Test2::Util::HashBase::VERSION
Truth table33%1/3
A || B
A= $Test2::Util::HashBase::HB_VERSIONB= $Test2::Util::HashBase::VERSION
ABresult
1X1
011
000
61 20689 ▶ $Test2::Util::HashBase::VERSION{$into} = $ver if !$Test2::Util::HashBase::VERSION{$into} || $Test2::Util::HashBase::VERSION{$into} > $ver;
Branch: 1 branch
BranchTrueFalseTotal
if not $Test2::Util::HashBase::VERSION{$into} or $Test2::Util::HashBase::VERSION{$into} > $ver 19467 1222 20689
Condition66%2/3
not $Test2::Util::HashBase::VERSION{$into} or $Test2::Util::HashBase::VERSION{$into} > $ver
l!l&&r!l&&!r
1946701222
MC/DC50%1/2
not $Test2::Util::HashBase::VERSION{$into} or $Test2::Util::HashBase::VERSION{$into} > $ver
not $Test2::Util::HashBase::VERSION{$into} $Test2::Util::HashBase::VERSION{$into} > $ver
Truth table66%2/3
not(A) or B
A= not $Test2::Util::HashBase::VERSION{$into}B= $Test2::Util::HashBase::VERSION{$into} > $ver
ABresult
1X1
011
000
62  
63 20689 my $isa = _isa($into);
64 20689 ▶ my $attr_list = $Test2::Util::HashBase::ATTR_LIST{$into} ||= [];
Condition100%2/2
$Test2::Util::HashBase::ATTR_LIST{$into} ||= []
l!l
122219467
MC/DC100%1/1
$Test2::Util::HashBase::ATTR_LIST{$into} ||= []
$Test2::Util::HashBase::ATTR_LIST{$into}
Truth table100%2/2
A
A= $Test2::Util::HashBase::ATTR_LIST{$into}
Aresult
11
00
65 20689 ▶ my $attr_subs = $Test2::Util::HashBase::ATTR_SUBS{$into} ||= {};
Condition100%2/2
$Test2::Util::HashBase::ATTR_SUBS{$into} ||= {}
l!l
122219467
MC/DC100%1/1
$Test2::Util::HashBase::ATTR_SUBS{$into} ||= {}
$Test2::Util::HashBase::ATTR_SUBS{$into}
Truth table100%2/2
A
A= $Test2::Util::HashBase::ATTR_SUBS{$into}
Aresult
11
00
66  
67 my %subs = (
68 ($into->can('new') ? () : (new => \&_new)),
69 18397 ▶ (map %{$Test2::Util::HashBase::ATTR_SUBS{$_} || {}}, @{$isa}[1 .. $#$isa]),
Condition100%2/2
$Test2::Util::HashBase::ATTR_SUBS{$_} || {}
l!l
18212185
MC/DC100%1/1
$Test2::Util::HashBase::ATTR_SUBS{$_} || {}
$Test2::Util::HashBase::ATTR_SUBS{$_}
Truth table100%2/2
A
A= $Test2::Util::HashBase::ATTR_SUBS{$_}
Aresult
11
00
70 (
71 map {
72 20689 ▶ my $p = substr($_, 0, 1);
Branch: 1 branch
BranchTrueFalseTotal
$into->can('new') ? : 16928 3761 20689
73 86799 my $x = $_;
74  
75 86799 ▶ my $spec = $SPEC{$p} || {reader => 1, writer => 1};
Condition100%2/2
$SPEC{$p} || {'reader', 1, 'writer', 1}
l!l
2819258607
MC/DC100%1/1
$SPEC{$p} || {'reader', 1, 'writer', 1}
$SPEC{$p}
Truth table100%2/2
A
A= $SPEC{$p}
Aresult
11
00
76  
77 86799 ▶ substr($x, 0, 1) = '' if $spec->{strip};
Branch: 1 branch
BranchTrueFalseTotal
if $spec->{"strip"} 28192 58607 86799
78 86799 push @$attr_list => $x;
79 86799 my ($sub, $attr) = (uc $x, $x);
80  
81 0 ▶ $attr_subs->{$sub} = sub() { $attr };
Subroutine __ANON__: not called CC=1 SCAR=1.2
82 86799 my %out = ($sub => $attr_subs->{$sub});
83  
84 86799 ▶ $out{$attr} = sub { $_[0]->{$attr} } if $spec->{reader};
Subroutine __ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
if $spec->{"reader"} 86189 610 86799
85 86799 ▶ $out{"set_$attr"} = sub { $_[0]->{$attr} = $_[1] } if $spec->{writer};
Subroutine __ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
if $spec->{"writer"} 58608 28191 86799
86 86799 ▶ $out{"set_$attr"} = sub { Carp::croak("'$attr' is read-only") } if $spec->{read_only};
Subroutine __ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
if $spec->{"read_only"} 24552 62247 86799
87 86799 ▶ $out{"set_$attr"} = sub { Carp::carp("set_$attr() is deprecated"); $_[0]->{$attr} = $_[1] } if $spec->{dep_writer};
Subroutine __ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
if $spec->{"dep_writer"} 1821 84978 86799
88  
89 86799 %out;
90 } @_
91 ),
92 );
93  
94 455 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
95 20689 *{"$into\::$_"} = $subs{$_} for keys %subs;
96 }
97  
98 3 ▶sub attr_list {
Subroutine attr_list: called CC=4 SCAR=14.3
Pod documented
99 3 my $class = shift;
100  
101 3 my $isa = _isa($class);
102  
103 3 my %seen;
104 15 my @list = grep { !$seen{$_}++ } map {
105 3 my @out;
106  
107 6 ▶ if (0.004 > ($Test2::Util::HashBase::VERSION{$_} || 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if (0.004 > ($Test2::Util::HashBase::VERSION{$_} || 0)) { } 0 6 6
Condition50%1/2
$Test2::Util::HashBase::VERSION{$_} || 0
l!l
60
MC/DC0%0/1
$Test2::Util::HashBase::VERSION{$_} || 0
$Test2::Util::HashBase::VERSION{$_}
Truth table50%1/2
A
A= $Test2::Util::HashBase::VERSION{$_}
Aresult
11
00
108 0 Carp::carp("$_ uses an inlined version of Test2::Util::HashBase too old to support attr_list()");
109 }
110 else {
111 6 my $list = $Test2::Util::HashBase::ATTR_LIST{$_};
112 6 ▶ @out = $list ? @$list : ()
Branch: 1 branch
BranchTrueFalseTotal
$list ? : 6 0 6
113 }
114  
115 6 @out;
116 } reverse @$isa;
117  
118 3 return @list;
119 }
120  
121 36948 ▶sub _new {
Subroutine _new: called CC=8 SCAR=20.8
122 36948 my $class = shift;
123  
124 36948 my $self;
125  
126 36948 ▶ if (@_ == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 1) { } 723 36225 36948
127 723 my $arg = shift;
128 723 my $type = ref($arg);
129  
130 723 ▶ if ($type eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq 'HASH') { } 721 2 723
131 721 $self = bless({%$arg}, $class)
132 }
133 else {
134 2 ▶ Carp::croak("Not sure what to do with '$type' in $class constructor")
Branch: 1 branch
BranchTrueFalseTotal
unless $type eq "ARRAY" 0 2 2
135 unless $type eq 'ARRAY';
136  
137 2 my %proto;
138 2 my @attributes = attr_list($class);
139 2 ▶ while (@$arg) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$arg) 9 1 10
140 9 my $val = shift @$arg;
141 9 ▶ my $key = shift @attributes or Carp::croak("Too many arguments for $class constructor");
Branch: 1 branch
BranchTrueFalseTotal
my $key = shift @attributes or Carp::croak("Too many arguments for $class constructor") 8 1 9
142 8 $proto{$key} = $val;
143 }
144  
145 1 $self = bless(\%proto, $class);
146 }
147 }
148 else {
149 36225 $self = bless({@_}, $class);
150 }
151  
152 $Test2::Util::HashBase::CAN_CACHE{$class} = $self->can('init')
153 36947 ▶ unless exists $Test2::Util::HashBase::CAN_CACHE{$class};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $Test2::Util::HashBase::CAN_CACHE{$class} 4844 32103 36947
154  
155 36947 ▶ $self->init if $Test2::Util::HashBase::CAN_CACHE{$class};
Branch: 1 branch
BranchTrueFalseTotal
if $Test2::Util::HashBase::CAN_CACHE{$class} 35820 1127 36947
156  
157 36897 $self;
158 }
159  
160 455 1;
161  
162 __END__
« blib/lib/Test/More.pm ↑ Summary blib/lib/Test2/Workflow.pm »