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