MongoDB/Role/_PrivateConstructor.pm

filter: Statementstmt 88.0% 22 / 25 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 87.5% 7 / 8 Podpod n/a totaltotal 65.9% 29 / 44 CC 3 SCAR 13.2
CC
3
Cov
67%
_new
9.9
BEGIN
1.6
BEGIN
1.0
CRAP 3.7
« MongoDB/_Server.pm ↑ Summary MongoDB/WriteConcern.pm »
1 # Copyright 2015 - present MongoDB, Inc.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14  
15 61 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 61 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 package MongoDB::Role::_PrivateConstructor;
18  
19 # MongoDB interface for a private constructor
20  
21 61 ▶use version;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 61 our $VERSION = 'v2.2.2';
23  
24 61 ▶use MongoDB::_Constants;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 61 ▶use Sub::Defer;
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 61 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
28  
29 # When assertions are enabled, the private constructor delegates to the
30 # public one, which checks required/isa assertions. When disabled,
31 # the private constructor blesses args directly to the class for speed.
32 61 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=4.7
33 61 my $NO_ASSERT_CONSTRUCTOR = <<'HERE';
34 my %done;
35 sub _new {
36 my $class = shift;
37 undefer_sub($class->can(q{new})) and $done{$class}++
38 unless $done{$class};
39 return bless {@_}, $class
40 }
41 HERE
42  
43 0 ▶ WITH_ASSERTS
Subroutine _new: not called CC=3 SCAR=23.0
Branch: 1 branch
BranchTrueFalseTotal
unless $done{$class} 0 0 0
Condition0%0/6
$done{$class} || undefer_sub($class->can('new')) && ++$done{$class}
l!l&&r!l&&!r
000
undefer_sub($class->can("new")) and ++$done{$class}
!ll&&!rl&&r
000
MC/DC0%0/3
$done{$class} || undefer_sub($class->can('new')) && ++$done{$class}
$done{$class} undefer_sub($class->can("new")) ++$done{$class}
Truth table0%0/4
A || B and C
A= $done{$class}B= undefer_sub($class->can("new"))C= ++$done{$class}
ABCresult
1XX1
0111
00X0
0100
44 ? eval 'sub _new { my $class = shift; $class->new(@_) }' ## no critic
45 : eval $NO_ASSERT_CONSTRUCTOR; ## no critic
46 }
47  
48 61 1;
« MongoDB/_Server.pm ↑ Summary MongoDB/WriteConcern.pm »