blib/lib/Perl/Structure/Hash/SubTypes.pm untested

filter: Statementstmt 0.0% 0 / 63 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 16 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 89 CC 5 SCAR 16.1
CC
5
Cov
0%
hashref_CHECK
12.0
hashref_CHECKTRACE
12.0
BEGIN
2.0
CRAP 5.0
1 ## no critic qw(ProhibitUselessNoCritic PodSpelling ProhibitExcessMainComplexity) # DEVELOPER DEFAULT 1a: allow unreachable & POD-commented code; SYSTEM SPECIAL 4: allow complex code outside subroutines, must be on line 1
2 package Perl::Structure::Hash::SubTypes;
3 use strict;
4 use warnings;
5 use Perl::Config; # don't use Perl::Types inside itself, in order to avoid circular includes
6 our $VERSION = 0.016_000;
7  
8 # [[[ CRITICS ]]]
9 ## no critic qw(ProhibitUselessNoCritic ProhibitMagicNumbers RequireCheckedSyscalls) # USER DEFAULT 1: allow numeric values & print operator
10 ## no critic qw(ProhibitUnreachableCode RequirePodSections RequirePodAtEnd) # DEVELOPER DEFAULT 1b: allow unreachable & POD-commented code, must be after line 1
11 ## no critic qw(RequireInterpolationOfMetachars) # USER DEFAULT 2: allow single-quoted control characters & sigils
12 ## no critic qw(Capitalization ProhibitMultiplePackages ProhibitReusedNames) # SYSTEM DEFAULT 3: allow multiple & lower case package names
13  
14 # [[[ EXPORTS ]]]
15 # DEV NOTE, CORRELATION #rp051: hard-coded list of RPerl data types and data structures
16 use Exporter 'import';
17 our @EXPORT = qw(
18 hashref_CHECK
19 hashref_CHECKTRACE
20 );
21 our @EXPORT_OK = qw();
22  
23 # [[[ HASH ]]]
24 # [[[ HASH ]]]
25 # [[[ HASH ]]]
26  
27 # a hash is an associative array, meaning a 1-dimensional list/vector/sequence/set of (key, value) pairs;
28 # we never use this type directly, instead we always use the hashref type,
29 # per LMPC #27: Thou Shalt Not Use Direct Access To Arrays & Hashes Stored In @ Or % Non-Scalar Variables
30 package hash;
31 use strict;
32 use warnings;
33 use parent qw(Perl::Structure::Hash);
34  
35 # [[[ HASH REF ]]]
36 # [[[ HASH REF ]]]
37 # [[[ HASH REF ]]]
38  
39 # ref to hash
40 package hashref;
41 use strict;
42 use warnings;
43 #use parent -norequire, qw(ref); # NEED REMOVE: properly replaced by line below?
44 use parent -norequire, qw(Perl::Structure::Hash::Reference);
45 use Carp;
46  
47 # [[[ SWITCH CONTEXT BACK TO PRIMARY PACKAGE FOR EXPORT TO WORK ]]]
48 package Perl::Structure::Hash::SubTypes;
49 use strict;
50 use warnings;
51  
52 use Perl::Config; # for 'use English;' etc.
53  
54 # [[[ TYPE-CHECKING ]]]
55  
56 sub hashref_CHECK {
57 { my void $RETURN_TYPE };
58 ( my $possible_hashref ) = @ARG;
59 if ( not( defined $possible_hashref ) ) {
60 croak(
61 "\nERROR EHVRV00, TYPE-CHECKING MISMATCH, PERLOPS_PERLTYPES:\nhashref value expected but undefined/null value found,\ncroaking"
62 );
63 }
64  
65 # if ( UNIVERSAL::isa( $possible_hashref, 'HASH' ) ) { # DEV NOTE: I believe these 2 lines are equivalent?
66 if ( not( main::PerlTypes_SvHROKp($possible_hashref) ) ) {
67 croak(
68 "\nERROR EHVRV01, TYPE-CHECKING MISMATCH, PERLOPS_PERLTYPES:\nhashref value expected but non-hashref value found,\ncroaking"
69 );
70 }
71 return;
72 }
73  
74 sub hashref_CHECKTRACE {
75 { my void $RETURN_TYPE };
76 ( my $possible_hashref, my $variable_name, my $subroutine_name ) = @ARG;
77 if ( not( defined $possible_hashref ) ) {
78 croak(
79 "\nERROR EHVRV00, TYPE-CHECKING MISMATCH, PERLOPS_PERLTYPES:\nhashref value expected but undefined/null value found,\nin variable $variable_name from subroutine $subroutine_name,\ncroaking"
80 );
81 }
82 if ( not( main::PerlTypes_SvHROKp($possible_hashref) ) ) {
83 croak(
84 "\nERROR EHVRV01, TYPE-CHECKING MISMATCH, PERLOPS_PERLTYPES:\nhashref value expected but non-hashref value found,\nin variable $variable_name from subroutine $subroutine_name,\ncroaking"
85 );
86 }
87 return;
88 }
89  
90 1; # end of package