File tree Expand file tree Collapse file tree 2 files changed +14
-7
lines changed
Expand file tree Collapse file tree 2 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -454,10 +454,20 @@ void PerlOMP_VERIFY_2D_AoA(SV *AoA) {
454454 }
455455}
456456
457- /* Helper function to verify element types */
458- bool is_float (SV * sv ) { return SvNOK (sv ); }
459- bool is_int (SV * sv ) { return SvIOKp (sv ); }
460- bool is_string (SV * sv ) { return SvPOK (sv ); }
457+ /* Checks if an SV is an integer, allowing for stored floats that are whole numbers */
458+ bool is_int (SV * sv ) {
459+ return SvIOK (sv ) || (SvNOK (sv ) && SvIV (sv ) == SvNV (sv ));
460+ }
461+
462+ /* Checks if an SV is a float, including cases where Perl stores it as an integer */
463+ bool is_float (SV * sv ) {
464+ return SvNOK (sv ) || (SvIOK (sv ) && SvIV (sv ) != SvNV (sv ));
465+ }
466+
467+ /* Checks if an SV is a string, ensuring it's not just a numeric representation */
468+ bool is_string (SV * sv ) {
469+ return SvPOK (sv ) || (!SvNOK (sv ) && !SvIOK (sv ));
470+ }
461471
462472void verify_1D_array_type (SV * array , bool (* type_check )(SV * ), const char * type_name ) {
463473 if (!is_array_ref (array )) {
Original file line number Diff line number Diff line change @@ -28,9 +28,6 @@ lives_ok { _PerlOMP_VERIFY_1D_Array($valid_1d_int) } "Valid 1D array passes veri
2828lives_ok { _PerlOMP_VERIFY_1D_INT_ARRAY($valid_1d_int ) } " Valid 1D integer array" ;
2929dies_ok { _PerlOMP_VERIFY_1D_INT_ARRAY($valid_1d_float ) } " Float 1D array should fail int verification" ;
3030
31- done_testing;
32- exit ;
33-
3431lives_ok { _PerlOMP_VERIFY_1D_FLOAT_ARRAY($valid_1d_float ) } " Valid 1D float array" ;
3532dies_ok { _PerlOMP_VERIFY_1D_FLOAT_ARRAY($valid_1d_int ) } " Int 1D array should fail float verification" ;
3633
You can’t perform that action at this time.
0 commit comments