Strict/UserConstraints.pm

filter: Statementstmt 100% 20 / 20 Branchbran 66.6% 4 / 6 Conditioncond 37.5% 3 / 8 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 75.5% 34 / 45 CC 7 SCAR 14.9
CC
7
Cov
79%
make_constraint
7.5
__ANON__
2.0
BEGIN
1.0
CRAP 4.4
« Strict.pm ↑ Summary
1 package Config::Strict::UserConstraints;
2 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 6 our $VERSION = '0.07';
6  
7 6 ▶use Carp qw(confess);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 6 ▶use Declare::Constraints::Simple-Library;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 #__PACKAGE__->install_into( 'Config::Strict' );
11  
12 4 ▶sub make_constraint {
Subroutine make_constraint: called CC=6 SCAR=20.2
Pod documented
13 4 my ( $class, $name, $sub, $message ) = @_;
14 # $name ||= '__ANON__'; TODO?
15 4 ▶ confess "No name" unless $name;
Branch: 1 branch
BranchTrueFalseTotal
unless $name 0 4 4
16 4 ▶ confess "Not a coderef" unless $sub and ref $sub and ref $sub eq 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
unless $sub and ref $sub and ref $sub eq "CODE" 0 4 4
Condition33%2/6
$sub and ref $sub and ref $sub eq "CODE"
!ll&&!rl&&r
004
$sub and ref $sub
!ll&&!rl&&r
004
MC/DC0%0/3
$sub and ref $sub and ref $sub eq "CODE"
$sub ref $sub ref $sub eq "CODE"
Truth table25%1/4
A and B and C
A= $subB= ref $subC= ref $sub eq "CODE"
ABCresult
0XX0
10X0
1100
1111
17 4 ▶ $message ||= "Value doesn't pass $name constraint";
Condition50%1/2
$message ||= "Value doesn't pass $name constraint"
l!l
04
MC/DC0%0/1
$message ||= "Value doesn't pass $name constraint"
$message
Truth table50%1/2
A
A= $message
Aresult
11
00
18  
19 # print "Making constraint $name...\n";
20 # This just registers $name as a DCS constraint and returns true:
21 constraint(
22 19 ▶ $name => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
23 # _result( $sub->( @_ ), $message );
24 19 ▶ $sub->( @_ ) ? _true : _false( $message );
Branch: 1 branch
BranchTrueFalseTotal
&$sub(@_) ? : 10 9 19
25 }
26 4 );
27 }
28  
29 6 1;
« Strict.pm ↑ Summary