summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorTAKAI Kousuke <62541129+t-a-k@users.noreply.github.com>2021-02-23 01:22:26 +0900
committerKarl Williamson <khw@cpan.org>2021-07-25 05:57:43 -0700
commit6738839e92f792ac9f6aa55589870decb54a9bfa (patch)
tree607b44726e1b750d930c7f436b6b88fd107e903a /t
parente79f3c064561c5843af40cda89f98bb44f956729 (diff)
downloadperl-6738839e92f792ac9f6aa55589870decb54a9bfa.tar.gz
t/op/numify.t: More tests to check if invalid Inf/NaNs are not numified
Diffstat (limited to 't')
-rw-r--r--t/op/numify.t14
1 files changed, 13 insertions, 1 deletions
diff --git a/t/op/numify.t b/t/op/numify.t
index 7a0db56537..f1f27a86a2 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 {