blib/script/data_type_scalar_test.pl untested

filter: Statementstmt 0.0% 0 / 58 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 66 CC 1 SCAR 6.9
CC
1
Cov
0%
string_dumperify
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 #!/usr/bin/env perl
2 use strict;
3 use warnings;
4 use Perl::Types;
5 our $VERSION = 0.003_021;
6  
7 ## no critic qw(ProhibitUselessNoCritic ProhibitMagicNumbers RequireCheckedSyscalls) # USER DEFAULT 1: allow numeric values & print operator
8 ## no critic qw(ProhibitUnreachableCode RequirePodSections RequirePodAtEnd PodSpelling) # DEVELOPER DEFAULT 1: allow unreachable & POD-commented code
9 ## no critic qw(ProhibitStringySplit ProhibitInterpolationOfLiterals) # DEVELOPER DEFAULT 2: allow string test values
10 ## no critic qw(RequireInterpolationOfMetachars) # USER DEFAULT 2: allow single-quoted control characters & sigils
11  
12 $Perl::DEBUG = 1;
13  
14 # UNCOMMENT TO ENABLE PERL TYPES FOR C++ OPS
15 #perltypes::types_enable('PERL');
16  
17 # UNCOMMENT TO ENABLE C++ TYPES FOR C++ OPS
18 perltypes::types_enable('CPP');
19  
20 # UNCOMMENT TO ENABLE C++ OPS
21 use Perl::Type::Integer_cpp; Perl::Type::Integer_cpp::cpp_load();
22 use Perl::Type::Number_cpp; Perl::Type::Number_cpp::cpp_load();
23 use Perl::Type::String_cpp; Perl::Type::String_cpp::cpp_load();
24  
25 #Perl::diag(q{in scalar_test.pl, have Perl__Type__Integer__MODE_ID() = '} . Perl__Type__Integer__MODE_ID() . "'\n");
26 #Perl::diag(q{in scalar_test.pl, have Perl__Type__Number__MODE_ID() = '} . Perl__Type__Number__MODE_ID() . "'\n");
27 #Perl::diag(q{in scalar_test.pl, have Perl__Type__String__MODE_ID() = '} . Perl__Type__String__MODE_ID() . "'\n");
28 Perl::diag(q{in scalar_test.pl, have main::Perl__Type__Integer__MODE_ID() = '} . main::Perl__Type__Integer__MODE_ID() . "'\n");
29 Perl::diag(q{in scalar_test.pl, have main::Perl__Type__Number__MODE_ID() = '} . main::Perl__Type__Number__MODE_ID() . "'\n");
30 Perl::diag(q{in scalar_test.pl, have main::Perl__Type__String__MODE_ID() = '} . main::Perl__Type__String__MODE_ID() . "'\n");
31  
32 # use Data::Dumper() to to stringify a string
33 sub string_dumperify {
34 { my string $RETURN_TYPE; }
35 ( my string $input_string ) = @_;
36 Perl::diag("in scalar_test.pl string_dumperify(), received have \$input_string =\n$input_string\n\n");
37 $input_string = Dumper( [$input_string] );
38 $input_string =~ s/^\s+|\s+$//xmsg; # strip leading whitespace
39 my @input_string_split = split "\n", $input_string;
40 $input_string = $input_string_split[1]; # only select the data line
41 return $input_string;
42 }
43  
44 # variable declarations
45 my integer $integer_retval;
46 my number $number_retval;
47 my string $string_retval;
48 my string $my_string;
49 my string $dumper_string;
50  
51 # loop to test for memory leaks
52 my integer $i_MAX = 0; # CONSTANT
53 for my integer $i ( 0 .. $i_MAX ) {
54 Perl::diag("in scalar_test.pl, top of for() loop $i/$i_MAX\n\n");
55  
56 # [[[ INTEGER TESTS ]]]
57  
58 # $string_retval = integer_to_string(); # TIV00; error PERLOPS EIV00, CPPOPS "Usage: integer_to_string(input_integer)"
59 # $string_retval = integer_to_string(undef); # TIV01; error EIV00
60 # $string_retval = integer_to_string(3); # TIV02
61 # $string_retval = integer_to_string(-17); # TIV03
62 # $string_retval = integer_to_string(-17.3); # TIV04; error EIV01
63 # $string_retval = integer_to_string('-17.3'); # TIV05; error EIV01
64 # $string_retval = integer_to_string([3]); # TIV06; error EIV01
65 # $string_retval = integer_to_string({a_key => 3}); # TIV07; error EIV01
66 # $string_retval = integer_to_string(-1_234_567_890); # TIV08
67 # $string_retval = integer_to_string(-1_234_567_890_000); # TIV09; error EIV01
68 # Perl::diag("in scalar_test.pl $i/$i_MAX, have \$string_retval = '$string_retval'\n");
69  
70 # $integer_retval = integer_typetest0(); # TIV10
71 # Perl::diag("in scalar_test.pl $i/$i_MAX, have \$integer_retval = $integer_retval\n");
72
73  
74 # $integer_retval = integer_typetest1(); # TIV20; error PERLOPS EIV00, CPPOPS "Usage: main::integer_typetest1(lucky_integer)"
75 # $integer_retval = integer_typetest1(undef); # TIV21; error EIV00
76 # $integer_retval = integer_typetest1(3); # TIV22
77 # $integer_retval = integer_typetest1(-17); # TIV23
78 # $integer_retval = integer_typetest1(-17.3); # TIV24; error EIV01
79 # $integer_retval = integer_typetest1('-17.3'); # TIV25; error EIV01
80 # $integer_retval = integer_typetest1([3]); # TIV26; error EIV01
81 # $integer_retval = integer_typetest1({a_key => 3}); # TIV27; error EIV01
82 ## $integer_retval = integer_typetest1(-1_234_567_890); # NOT TEST-WORTHY: arithmetic overflow, incorrect results
83 # $integer_retval = integer_typetest1(-234_567_890); # TIV28
84 # $integer_retval = integer_typetest1(-1_234_567_890_000); # TIV29; error EIV01
85 # Perl::diag("in scalar_test.pl $i/$i_MAX, have \$integer_retval = $integer_retval\n");
86  
87 # [[[ NUMBER TESTS ]]]
88  
89 # $string_retval = number_to_string(); # TNV00; error PERLOPS ENV00, CPPOPS "Usage: number_to_string(input_number)"
90 # $string_retval = number_to_string(undef); # TNV01; error ENV00
91 # $string_retval = number_to_string(3); # TNV02
92 # $string_retval = number_to_string(-17); # TNV03
93 # $string_retval = number_to_string(-17.3); # TNV04
94 # $string_retval = number_to_string('-17.3'); # TNV05; error ENV01
95 # $string_retval = number_to_string([3]); # TNV06; error ENV01
96 # $string_retval = number_to_string({a_key => 3}); # TNV07; error ENV01
97 # $string_retval = number_to_string(3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679); # TNV08
98 $string_retval = number_to_string(1_234_567.890_123_456); # TNV08
99 Perl::diag("in scalar_test.pl $i/$i_MAX, have \$string_retval = '$string_retval'\n");
100  
101 # $number_retval = number_typetest0(); # TNV10
102 # Perl::diag("in scalar_test.pl $i/$i_MAX, have \$number_retval = $number_retval\n");
103  
104 croak('done');
105  
106 # $number_retval = number_typetest1(); # TNV20; error PERLOPS ENV00, CPPOPS "Usage: main::number_typetest1(lucky_number)"
107 # $number_retval = number_typetest1(undef); # TNV21; error ENV00
108 # $number_retval = number_typetest1(3); # TNV22
109 # $number_retval = number_typetest1(-17); # TNV23
110 # $number_retval = number_typetest1(-17.3); # TNV24
111 # $number_retval = number_typetest1('-17.3'); # TNV25; error ENV01
112 # $number_retval = number_typetest1([3]); # TNV26; error ENV01
113 # $number_retval = number_typetest1({a_key => 3}); # TNV27; error ENV01
114 # $number_retval = number_typetest1(3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679); # TNV28
115 # Perl::diag("in scalar_test.pl $i/$i_MAX, have \$number_retval = $number_retval\n");
116  
117 # [[[ STRING TESTS ]]]
118  
119 # $string_retval = string_to_string(); # TPV00; error PERLOPS EPV00, CPPOPS "Usage: string_to_string(input_string)"
120 # $string_retval = string_to_string(undef); # TPV01; error EPV00
121 # $string_retval = string_to_string(3); # TPV02; error EPV01
122 # $string_retval = string_to_string(-17); # TPV03; error EPV01
123 # $string_retval = string_to_string(-17.3); # TPV04; error EPV01
124 # $string_retval = string_to_string('-17.3'); # TPV05
125 # $string_retval = string_to_string([3]); # TPV06; error EPV01
126 # $string_retval = string_to_string({a_key => 3}); # TPV07; error EPV01
127 # $string_retval = string_to_string('Melange'); # TPV08
128 # $string_retval = string_to_string("\nThe Spice Extends Life\nThe Spice Expands Consciousness\nThe Spice Is Vital To Space Travel\n"); # TPV09
129 # Perl::diag("in scalar_test.pl $i/$i_MAX, have \$string_retval =\n$string_retval\n");
130  
131 # DEV NOTE: in English grammar, I prefer the comma after the right-quote
132 $my_string = '\'I am a single-quoted string, in a single-quoted string with back-slash control chars\', the first string said introspectively.' ; # TPV10
133 # $my_string = '"I am a double-quoted string, in a single-quoted string with no back-slash chars", the second string observed.'; # TPV11
134 # $my_string = "'I am a single-quoted string, in a double-quoted string with no back-slash chars', the third string added."; # TPV12
135 # $my_string = "\"I am a double-quoted string, in a double-quoted string with back-slash control chars\", the fourth string offered."; # TPV13
136 # $my_string = '\'I am a single-quoted string, in a single-quoted string with back-slash control and \ display \ chars\', the fifth string shouted.'; # TPV14
137 # $my_string = '"I am a double-quoted string, in a single-quoted string with back-slash \ display \ chars", the sixth string hollered.'; # TPV15
138 # $my_string = "'I am a single-quoted string, in a double-quoted string with back-slash \\ display \\ chars', the seventh string yelled."; # TPV16
139 # $my_string = "\"I am a double-quoted string, in a double-quoted string with back-slash control and \\ display \\ chars\", the eighth string belted."; # TPV17
140  
141 # $my_string = q{'I am a single-quoted string, in a single-quoted q{} string with no back-slash chars', the ninth string chimed in.}; # TPV20
142 # $my_string = q{"I am a double-quoted string, in a single-quoted q{} string with no back-slash chars", the tenth string opined.}; # TPV21
143 # $my_string = qq{'I am a single-quoted string, in a double-quoted qq{} string with no back-slash chars', the eleventh string asserted.}; # TPV22
144 # $my_string = qq{"I am a double-quoted string, in a double-quoted qq{} string with no back-slash chars", the twelfth string insisted.}; # TPV23
145 # $my_string = q{'I am a single-quoted string, in a single-quoted q{} string with back-slash \ display \ chars', the thirteenth string whispered.}; # TPV24
146 # $my_string = q{"I am a double-quoted string, in a single-quoted q{} string with back-slash \ display \ chars", the fourteenth string breathed.}; # TPV25
147 # $my_string = qq{'I am a single-quoted string, in a double-quoted qq{} string with back-slash \\ display \\ chars', the fifteenth string mouthed.}; # TPV26
148 # $my_string = qq{"I am a double-quoted string, in a double-quoted qq{} string with back-slash \\ display \\ chars", the sixteenth string implied.}; # TPV27
149  
150 =disable
151 Perl::diag("in scalar_test.pl $i/$i_MAX, have \$my_string =\n$my_string\n\n");
152 $dumper_string = Dumper([$my_string]); # retrieve Dumper()'s version of the stringified string
153 $dumper_string =~ s/^\s+|\s+$//xmsg; # strip leading whitespace
154 my @dumper_split = split "\n", $dumper_string;
155 $dumper_string = $dumper_split[1]; # only select the data line
156 # Perl::diag("in scalar_test.pl $i/$i_MAX, have Dumper([\$my_string]) =\n" . Dumper([$my_string]) . "\n");
157 =cut
158  
159 $dumper_string = string_dumperify($my_string);
160 $string_retval = string_to_string($my_string);
161 Perl::diag("in scalar_test.pl $i/$i_MAX, have \$string_retval =\n$string_retval STRINGIFY\n\n");
162 Perl::diag("in scalar_test.pl $i/$i_MAX, have \$dumper_string =\n$dumper_string DUMPERIFY\n\n");
163  
164 # $string_retval = string_typetest0(); # TPV30
165 # Perl::diag("in scalar_test.pl $i/$i_MAX, have \$string_retval =\n$string_retval\n");
166  
167 # $string_retval = string_typetest1(); # TPV40; error PERLOPS EPV00, CPPOPS "Usage: main::string_typetest1(lucky_string)"
168 # $string_retval = string_typetest1(undef); # TPV41; error EPV00
169 # $string_retval = string_typetest1(3); # TPV42; error EPV01
170 # $string_retval = string_typetest1(-17); # TPV43; error EPV01
171 # $string_retval = string_typetest1(-17.3); # TPV44; error EPV01
172 # $string_retval = string_typetest1('-17.3'); # TPV45
173 # $string_retval = string_typetest1([3]); # TPV46; error EPV01
174 # $string_retval = string_typetest1({a_key => 3}); # TPV47; error EPV01
175 $string_retval = string_typetest1('Melange'); # TPV48
176 # $string_retval = string_typetest1("\nThe Spice Extends Life\nThe Spice Expands Consciousness\nThe Spice Is Vital To Space Travel\n"); # TPV49
177 # Perl::diag("in scalar_test.pl $i/$i_MAX, have \$string_retval =\n$string_retval\n");
178  
179 croak('Done for now, croaking');
180 }
181  
182 #croak('Done for now, croaking');
183