From 6738839e92f792ac9f6aa55589870decb54a9bfa Mon Sep 17 00:00:00 2001 From: TAKAI Kousuke <62541129+t-a-k@users.noreply.github.com> Date: Tue, 23 Feb 2021 01:22:26 +0900 Subject: [PATCH] t/op/numify.t: More tests to check if invalid Inf/NaNs are not numified --- t/op/numify.t | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/t/op/numify.t b/t/op/numify.t index 7a0db565374f..f1f27a86a287 100644 --- a/t/op/numify.t +++ b/t/op/numify.t @@ -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], @@ -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 {