line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# [[[ HEADER ]]] |
2
|
|
|
|
|
|
|
package RPerl::DataType::Boolean; |
3
|
7
|
|
|
7
|
|
39
|
use strict; |
|
7
|
|
|
|
|
11
|
|
|
7
|
|
|
|
|
165
|
|
4
|
7
|
|
|
7
|
|
32
|
use warnings; |
|
7
|
|
|
|
|
10
|
|
|
7
|
|
|
|
|
133
|
|
5
|
7
|
|
|
7
|
|
29
|
use RPerl::AfterSubclass; |
|
7
|
|
|
|
|
10
|
|
|
7
|
|
|
|
|
868
|
|
6
|
|
|
|
|
|
|
our $VERSION = 0.009_000; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# [[[ OO INHERITANCE ]]] |
9
|
7
|
|
|
7
|
|
37
|
use parent qw(RPerl::DataType::Scalar); |
|
7
|
|
|
|
|
12
|
|
|
7
|
|
|
|
|
30
|
|
10
|
7
|
|
|
7
|
|
210
|
use RPerl::DataType::Scalar; |
|
7
|
|
|
|
|
11
|
|
|
7
|
|
|
|
|
182
|
|
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
|
|
|
|
|
|
|
# a boolean is a binary boolean value, the only valid values are 0 (false) or 1 (true) |
19
|
|
|
|
|
|
|
package # hide from PAUSE indexing |
20
|
|
|
|
|
|
|
boolean; |
21
|
7
|
|
|
7
|
|
28
|
use strict; |
|
7
|
|
|
|
|
10
|
|
|
7
|
|
|
|
|
93
|
|
22
|
7
|
|
|
7
|
|
24
|
use warnings; |
|
7
|
|
|
|
|
11
|
|
|
7
|
|
|
|
|
206
|
|
23
|
7
|
|
|
7
|
|
29
|
use parent qw(RPerl::DataType::Boolean); |
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
18
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# [[[ PRE-DECLARED TYPES ]]] |
26
|
|
|
|
|
|
|
package # hide from PAUSE indexing |
27
|
|
|
|
|
|
|
void; |
28
|
|
|
|
|
|
|
package # hide from PAUSE indexing |
29
|
|
|
|
|
|
|
unsigned_integer; |
30
|
|
|
|
|
|
|
package # hide from PAUSE indexing |
31
|
|
|
|
|
|
|
integer; |
32
|
|
|
|
|
|
|
package # hide from PAUSE indexing |
33
|
|
|
|
|
|
|
number; |
34
|
|
|
|
|
|
|
package # hide from PAUSE indexing |
35
|
|
|
|
|
|
|
character; |
36
|
|
|
|
|
|
|
package # hide from PAUSE indexing |
37
|
|
|
|
|
|
|
string; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# [[[ SWITCH CONTEXT BACK TO PRIMARY PACKAGE ]]] |
40
|
|
|
|
|
|
|
package RPerl::DataType::Boolean; |
41
|
7
|
|
|
7
|
|
509
|
use strict; |
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
131
|
|
42
|
7
|
|
|
7
|
|
26
|
use warnings; |
|
7
|
|
|
|
|
12
|
|
|
7
|
|
|
|
|
165
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# [[[ EXPORTS ]]] |
45
|
7
|
|
|
7
|
|
2481
|
use RPerl::Exporter 'import'; |
|
7
|
|
|
|
|
18
|
|
|
7
|
|
|
|
|
40
|
|
46
|
|
|
|
|
|
|
our @EXPORT = qw(boolean_CHECK boolean_CHECKTRACE boolean_to_unsigned_integer boolean_to_integer boolean_to_number boolean_to_character boolean_to_string); |
47
|
|
|
|
|
|
|
our @EXPORT_OK = qw(boolean__typetest0 boolean__typetest1); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# [[[ TYPE-CHECKING ]]] |
50
|
|
|
|
|
|
|
sub boolean_CHECK { |
51
|
0
|
|
|
0
|
|
|
{ my void $RETURN_TYPE }; |
|
0
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
( my $possible_boolean ) = @ARG; |
53
|
0
|
0
|
|
|
|
|
if ( not( defined $possible_boolean ) ) { |
54
|
|
|
|
|
|
|
# croak( "\nERROR EBV00, TYPE-CHECKING MISMATCH, PERLOPS_PERLTYPES:\nboolean value expected but undefined/null value found,\ncroaking" ); |
55
|
0
|
|
|
|
|
|
die( "\nERROR EBV00, TYPE-CHECKING MISMATCH, PERLOPS_PERLTYPES:\nboolean value expected but undefined/null value found,\ndying\n" ); |
56
|
|
|
|
|
|
|
} |
57
|
0
|
0
|
|
|
|
|
if ( not( main::RPerl_SvBOKp($possible_boolean) ) ) { |
58
|
|
|
|
|
|
|
# croak( "\nERROR EBV01, TYPE-CHECKING MISMATCH, PERLOPS_PERLTYPES:\nboolean value expected but non-boolean value found,\ncroaking" ); |
59
|
0
|
|
|
|
|
|
die( "\nERROR EBV01, TYPE-CHECKING MISMATCH, PERLOPS_PERLTYPES:\nboolean value expected but non-boolean value found,\ndying\n" ); |
60
|
|
|
|
|
|
|
} |
61
|
0
|
|
|
|
|
|
return; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
sub boolean_CHECKTRACE { |
64
|
0
|
|
|
0
|
|
|
{ my void $RETURN_TYPE }; |
|
0
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
( my $possible_boolean, my $variable_name, my $subroutine_name ) = @ARG; |
66
|
0
|
0
|
|
|
|
|
if ( not( defined $possible_boolean ) ) { |
67
|
|
|
|
|
|
|
# croak( "\nERROR EBV00, TYPE-CHECKING MISMATCH, PERLOPS_PERLTYPES:\nboolean value expected but undefined/null value found,\nin variable " . $variable_name . " from subroutine " . $subroutine_name . ",\ncroaking" ); |
68
|
0
|
|
|
|
|
|
die( "\nERROR EBV00, TYPE-CHECKING MISMATCH, PERLOPS_PERLTYPES:\nboolean value expected but undefined/null value found,\nin variable " . $variable_name . " from subroutine " . $subroutine_name . ",\ndying\n" ); |
69
|
|
|
|
|
|
|
} |
70
|
0
|
0
|
|
|
|
|
if ( not( main::RPerl_SvBOKp($possible_boolean) ) ) { |
71
|
|
|
|
|
|
|
# croak( "\nERROR EBV01, TYPE-CHECKING MISMATCH, PERLOPS_PERLTYPES:\nboolean value expected but non-boolean value found,\nin variable " . $variable_name . " from subroutine " . $subroutine_name . ",\ncroaking" ); |
72
|
0
|
|
|
|
|
|
die( "\nERROR EBV01, TYPE-CHECKING MISMATCH, PERLOPS_PERLTYPES:\nboolean value expected but non-boolean value found,\nin variable " . $variable_name . " from subroutine " . $subroutine_name . ",\ndying\n" ); |
73
|
|
|
|
|
|
|
} |
74
|
0
|
|
|
|
|
|
return; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# [[[ UNSIGNED INTEGERIFY ]]] |
78
|
|
|
|
|
|
|
sub boolean_to_unsigned_integer { |
79
|
0
|
|
|
0
|
|
|
{ my unsigned_integer $RETURN_TYPE }; |
|
0
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
(my boolean $input_boolean) = @ARG; |
81
|
|
|
|
|
|
|
# boolean_CHECK($input_boolean); |
82
|
0
|
|
|
|
|
|
boolean_CHECKTRACE( $input_boolean, '$input_boolean', 'boolean_to_unsigned_integer()' ); |
83
|
0
|
|
|
|
|
|
return $input_boolean; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
# [[[ INTEGERIFY ]]] |
87
|
|
|
|
|
|
|
sub boolean_to_integer { |
88
|
0
|
|
|
0
|
|
|
{ my integer $RETURN_TYPE }; |
|
0
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
(my boolean $input_boolean) = @ARG; |
90
|
|
|
|
|
|
|
# boolean_CHECK($input_boolean); |
91
|
0
|
|
|
|
|
|
boolean_CHECKTRACE( $input_boolean, '$input_boolean', 'boolean_to_integer()' ); |
92
|
0
|
|
|
|
|
|
return $input_boolean; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
# [[[ NUMBERIFY ]]] |
96
|
|
|
|
|
|
|
sub boolean_to_number { |
97
|
0
|
|
|
0
|
|
|
{ my number $RETURN_TYPE }; |
|
0
|
|
|
|
|
|
|
98
|
0
|
|
|
|
|
|
(my boolean $input_boolean) = @ARG; |
99
|
|
|
|
|
|
|
# boolean_CHECK($input_boolean); |
100
|
0
|
|
|
|
|
|
boolean_CHECKTRACE( $input_boolean, '$input_boolean', 'boolean_to_number()' ); |
101
|
0
|
|
|
|
|
|
return $input_boolean * 1.0; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
# [[[ CHARACTERIFY ]]] |
105
|
|
|
|
|
|
|
sub boolean_to_character { |
106
|
0
|
|
|
0
|
|
|
{ my character $RETURN_TYPE }; |
|
0
|
|
|
|
|
|
|
107
|
0
|
|
|
|
|
|
(my boolean $input_boolean) = @ARG; |
108
|
|
|
|
|
|
|
# boolean_CHECK($input_boolean); |
109
|
0
|
|
|
|
|
|
boolean_CHECKTRACE( $input_boolean, '$input_boolean', 'boolean_to_character()' ); |
110
|
0
|
|
|
|
|
|
my string $tmp_string = boolean_to_string($input_boolean); |
111
|
0
|
|
|
|
|
|
return substr $tmp_string, 0, 1; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
# [[[ STRINGIFY ]]] |
115
|
|
|
|
|
|
|
sub boolean_to_string { |
116
|
0
|
|
|
0
|
|
|
{ my string $RETURN_TYPE }; |
|
0
|
|
|
|
|
|
|
117
|
0
|
|
|
|
|
|
( my $input_boolean ) = @ARG; |
118
|
|
|
|
|
|
|
# boolean_CHECK($input_boolean); |
119
|
0
|
|
|
|
|
|
boolean_CHECKTRACE( $input_boolean, '$input_boolean', 'boolean_to_string()' ); |
120
|
0
|
|
|
|
|
|
return "$input_boolean"; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
# [[[ TYPE TESTING ]]] |
124
|
|
|
|
|
|
|
sub boolean__typetest0 { |
125
|
0
|
|
|
0
|
|
|
{ my boolean $RETURN_TYPE }; |
|
0
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
# DEV NOTE: maintain independence from Integer data type, re-implement integer_to_boolean() here |
127
|
|
|
|
|
|
|
# my boolean $retval = integer_to_boolean(main::RPerl__DataType__Boolean__MODE_ID()); |
128
|
0
|
|
|
|
|
|
my boolean $retval = 1; |
129
|
0
|
0
|
|
|
|
|
if (main::RPerl__DataType__Boolean__MODE_ID() == 0) { $retval = 0; } |
|
0
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
# RPerl::diag("in PERLOPS_PERLTYPES boolean__typetest0(), have \$retval = $retval\n"); |
131
|
0
|
|
|
|
|
|
return $retval; |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
sub boolean__typetest1 { |
134
|
0
|
|
|
0
|
|
|
{ my boolean $RETURN_TYPE }; |
|
0
|
|
|
|
|
|
|
135
|
0
|
|
|
|
|
|
( my boolean $lucky_boolean ) = @ARG; |
136
|
|
|
|
|
|
|
# boolean_CHECK($lucky_boolean); |
137
|
0
|
|
|
|
|
|
boolean_CHECKTRACE( $lucky_boolean, '$lucky_boolean', 'boolean__typetest1()' ); |
138
|
|
|
|
|
|
|
# RPerl::diag('in PERLOPS_PERLTYPES boolean__typetest1(), received $lucky_boolean = ' . boolean_to_string($lucky_boolean) . "\n"); |
139
|
|
|
|
|
|
|
# DEV NOTE: maintain independence from Integer data type, re-implement integer_to_boolean() here |
140
|
0
|
|
|
|
|
|
my boolean $retval = 1; |
141
|
0
|
0
|
|
|
|
|
if (($lucky_boolean + main::RPerl__DataType__Boolean__MODE_ID()) == 0) { $retval = 0; } |
|
0
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
# RPerl::diag("in PERLOPS_PERLTYPES boolean__typetest1(), have \$retval = $retval\n"); |
143
|
0
|
|
|
|
|
|
return $retval; |
144
|
|
|
|
|
|
|
# return integer_to_boolean( $lucky_boolean + main::RPerl__DataType__Boolean__MODE_ID() ); |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
1; # end of class |