File Coverage

blib/lib/RPerl/DataType/UnsignedInteger.pm
Criterion Covered Total %
statement 42 82 51.2
branch 0 14 0.0
condition n/a
subroutine 14 23 60.8
pod 0 9 0.0
total 56 128 43.7


line stmt bran cond sub pod time code
1             # [[[ HEADER ]]]
2             package RPerl::DataType::UnsignedInteger;
3 9     9   58 use strict;
  9         21  
  9         227  
4 9     9   47 use warnings;
  9         20  
  9         193  
5 9     9   44 use RPerl::AfterSubclass;
  9         21  
  9         1340  
6             our $VERSION = 0.004_000;
7              
8             # [[[ OO INHERITANCE ]]]
9 9     9   64 use parent qw(RPerl::DataType::Scalar);
  9         22  
  9         48  
10 9     9   532 use RPerl::DataType::Scalar;
  9         21  
  9         301  
11              
12             # [[[ CRITICS ]]]
13             ## no critic qw(ProhibitUselessNoCritic ProhibitMagicNumbers RequireCheckedSyscalls) # USER DEFAULT 1: allow numeric values & print operator
14             ## no critic qw(RequireInterpolationOfMetachars) # USER DEFAULT 2: allow single-quoted control characters & sigils
15             ## no critic qw(Capitalization ProhibitMultiplePackages ProhibitReusedNames) # SYSTEM DEFAULT 3: allow multiple & lower case package names
16              
17             # [[[ SUB-TYPES ]]]
18             # an unsigned_integer is a whole number greater or equal to zero, it has no floating-pointer (fractional/decimal) component or negative value
19             package # hide from PAUSE indexing
20             unsigned_integer;
21 9     9   51 use strict;
  9         18  
  9         172  
22 9     9   45 use warnings;
  9         30  
  9         242  
23 9     9   47 use parent qw(RPerl::DataType::UnsignedInteger);
  9         20  
  9         37  
24              
25             package # hide from PAUSE indexing
26             constant_unsigned_integer;
27 9     9   695 use strict;
  9         19  
  9         178  
28 9     9   42 use warnings;
  9         21  
  9         239  
29 9     9   52 use parent qw(RPerl::DataType::UnsignedInteger);
  9         19  
  9         40  
30              
31             # [[[ PRE-DECLARED TYPES ]]]
32             package # hide from PAUSE indexing
33             boolean;
34             package # hide from PAUSE indexing
35             integer;
36             package # hide from PAUSE indexing
37             number;
38             package # hide from PAUSE indexing
39             character;
40             package # hide from PAUSE indexing
41             string;
42              
43             # [[[ SWITCH CONTEXT BACK TO PRIMARY PACKAGE ]]]
44             package RPerl::DataType::UnsignedInteger;
45 9     9   668 use strict;
  9         19  
  9         166  
46 9     9   44 use warnings;
  9         15  
  9         245  
47              
48             # [[[ EXPORTS ]]]
49 9     9   48 use Exporter 'import';
  9         21  
  9         5207  
50             our @EXPORT = qw(unsigned_integer_CHECK unsigned_integer_CHECKTRACE unsigned_integer_to_boolean unsigned_integer_to_integer unsigned_integer_to_number unsigned_integer_to_character unsigned_integer_to_string);
51              
52             # [[[ TYPE-CHECKING ]]]
53             #our void $unsigned_integer_CHECK = sub {
54             sub unsigned_integer_CHECK {
55 0     0 0   ( my $possible_unsigned_integer ) = @_;
56 0 0         if ( not( defined $possible_unsigned_integer ) ) {
57 0           croak("\nERROR EIV00, TYPE-CHECKING MISMATCH, PERLOPS_PERLTYPES:\nunsigned_integer value expected but undefined/null value found,\ncroaking");
58             }
59 0 0         if ( not( main::RPerl_SvUIOKp($possible_unsigned_integer) ) ) {
60 0           croak("\nERROR EIV01, TYPE-CHECKING MISMATCH, PERLOPS_PERLTYPES:\nunsigned_integer value expected but non-unsigned_integer value found,\ncroaking");
61             }
62             }
63             #our void $unsigned_integer_CHECKTRACE = sub {
64             sub unsigned_integer_CHECKTRACE {
65 0     0 0   ( my $possible_unsigned_integer, my $variable_name, my $subroutine_name ) = @_;
66 0 0         if ( not( defined $possible_unsigned_integer ) ) {
67 0           croak(
68             "\nERROR EIV00, TYPE-CHECKING MISMATCH, PERLOPS_PERLTYPES:\nunsigned_integer value expected but undefined/null value found,\nin variable $variable_name from subroutine $subroutine_name,\ncroaking"
69             );
70             }
71 0 0         if ( not( main::RPerl_SvUIOKp($possible_unsigned_integer) ) ) {
72 0           croak(
73             "\nERROR EIV01, TYPE-CHECKING MISMATCH, PERLOPS_PERLTYPES:\nunsigned_integer value expected but non-unsigned_integer value found,\nin variable $variable_name from subroutine $subroutine_name,\ncroaking"
74             );
75             }
76             }
77              
78             # [[[ BOOLEANIFY ]]]
79             #our boolean $unsigned_integer_to_boolean = sub {
80             sub unsigned_integer_to_boolean {
81 0     0 0   ( my unsigned_integer $input_unsigned_integer ) = @_;
82             # unsigned_integer_CHECK($input_unsigned_integer);
83 0           unsigned_integer_CHECKTRACE( $input_unsigned_integer, '$input_unsigned_integer', 'unsigned_integer_to_boolean()' );
84 0 0         if ( $input_unsigned_integer == 0 ) { return 0; }
  0            
85 0           else { return 1; }
86             }
87              
88             # [[[ INTEGERIFY ]]]
89             #our integer $unsigned_integer_to_integer = sub {
90             sub unsigned_integer_to_integer {
91 0     0 0   ( my unsigned_integer $input_unsigned_integer ) = @_;
92             # unsigned_integer_CHECK($input_unsigned_integer);
93 0           unsigned_integer_CHECKTRACE( $input_unsigned_integer, '$input_unsigned_integer', 'unsigned_integer_to_integer()' );
94 0           return $input_unsigned_integer;
95             }
96              
97             # [[[ NUMBERIFY ]]]
98             #our number $unsigned_integer_to_number = sub {
99             sub unsigned_integer_to_number {
100 0     0 0   ( my unsigned_integer $input_unsigned_integer ) = @_;
101             # unsigned_integer_CHECK($input_unsigned_integer);
102 0           unsigned_integer_CHECKTRACE( $input_unsigned_integer, '$input_unsigned_integer', 'unsigned_integer_to_number()' );
103 0           return $input_unsigned_integer * 1.0;
104             }
105              
106             # [[[ CHARACTERIFY ]]]
107             #our character $unsigned_integer_to_character = sub {
108             sub unsigned_integer_to_character {
109 0     0 0   ( my unsigned_integer $input_unsigned_integer ) = @_;
110             # unsigned_integer_CHECK($input_unsigned_integer);
111 0           unsigned_integer_CHECKTRACE( $input_unsigned_integer, '$input_unsigned_integer', 'unsigned_integer_to_character()' );
112 0           my string $tmp_string = unsigned_integer_to_string($input_unsigned_integer);
113 0 0         if ( $tmp_string eq q{} ) { return q{}; }
  0            
114 0           else { return substr $tmp_string, 0, 1; }
115             }
116              
117             # [[[ STRINGIFY ]]]
118             #our string $unsigned_integer_to_string = sub {
119             sub unsigned_integer_to_string {
120 0     0 0   ( my unsigned_integer $input_unsigned_integer ) = @_;
121             # unsigned_integer_CHECK($input_unsigned_integer);
122 0           unsigned_integer_CHECKTRACE( $input_unsigned_integer, '$input_unsigned_integer', 'unsigned_integer_to_string()' );
123              
124             # RPerl::diag("in PERLOPS_PERLTYPES unsigned_integer_to_string(), received \$input_unsigned_integer = $input_unsigned_integer\n");
125             # RPerl::diag("in PERLOPS_PERLTYPES unsigned_integer_to_string()...\n");
126              
127             # DEV NOTE: disable old stringify w/out underscores
128             # return "$input_unsigned_integer";
129              
130 0           my string $retval = reverse "$input_unsigned_integer";
131 0           $retval =~ s/(\d{3})/$1_/gxms;
132 0 0         if ( ( substr $retval, -1, 1 ) eq '_' ) { chop $retval; }
  0            
133 0           $retval = reverse $retval;
134              
135             # RPerl::diag('in PERLOPS_PERLTYPES unsigned_integer_to_string(), have $retval = ' . q{'} . $retval . q{'} . "\n");
136 0           return $retval;
137             }
138              
139             # [[[ TYPE TESTING ]]]
140             #our unsigned_integer $unsigned_integer__typetest0 = sub {
141             sub unsigned_integer__typetest0 {
142 0     0 0   my unsigned_integer $retval = ( 21 / 7 ) + main::RPerl__DataType__UnsignedInteger__MODE_ID(); # return unsigned_integer (not number) value, don't do (22 / 7) etc.
143              
144             # RPerl::diag("in PERLOPS_PERLTYPES unsigned_integer__typetest0(), have \$retval = $retval\n");
145 0           return ($retval);
146             }
147              
148             #our unsigned_integer $unsigned_integer__typetest1 = sub {
149             sub unsigned_integer__typetest1 {
150 0     0 0   ( my unsigned_integer $lucky_unsigned_integer ) = @_;
151             # unsigned_integer_CHECK($lucky_unsigned_integer);
152 0           unsigned_integer_CHECKTRACE( $lucky_unsigned_integer, '$lucky_unsigned_integer', 'unsigned_integer__typetest1()' );
153              
154             # RPerl::diag('in PERLOPS_PERLTYPES unsigned_integer__typetest1(), received $lucky_unsigned_integer = ' . unsigned_integer_to_string($lucky_unsigned_integer) . "\n");
155 0           return ( ( $lucky_unsigned_integer * 2 ) + main::RPerl__DataType__UnsignedInteger__MODE_ID() );
156             }
157              
158             1; # end of class