Skip to content

Commit

Permalink
t/op/numify.t: More tests to check if invalid Inf/NaNs are not numified
Browse files Browse the repository at this point in the history
  • Loading branch information
t-a-k authored and khwilliamson committed Jul 25, 2021
1 parent e79f3c0 commit 6738839
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion t/op/numify.t
Expand Up @@ -11,6 +11,11 @@ BEGIN {
use strict;
use warnings;

# Quick test if NV supports infinities.
# Note that this would be $Config{d_double_has_inf}, but this is only valid
# if NV is configured as double.
my $nv_has_inf = do { no warnings; 'inf' > 0 };

foreach ([' +3', 3, 0],
["10.\t", 10, 0],
['abc', 0, 1],
Expand All @@ -22,7 +27,14 @@ foreach ([' +3', 3, 0],
['- 0x789', 0, 1],
['0b101', 0, 1],
['-3.14', -3.14, 0],
['- 3.14', 0, 1]) {
['- 3.14', 0, 1],
($nv_has_inf ?
(['+infinity ', '+Inf', 0],
[' -infin', '-Inf', 1],
['+ inf', 0, 1],
['+-inf', 0, 1]) :
())
) {
my ($str, $num, $warn) = @$_;

my $code = sub {
Expand Down

0 comments on commit 6738839

Please sign in to comment.