This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Test subnormals with quadmath
authorJarkko Hietaniemi <jhi@iki.fi>
Thu, 18 Aug 2016 01:37:07 +0000 (21:37 -0400)
committerJarkko Hietaniemi <jhi@iki.fi>
Thu, 18 Aug 2016 02:13:38 +0000 (22:13 -0400)
t/op/sprintf2.t

index 11f12a3..016a2d6 100644 (file)
@@ -894,4 +894,24 @@ SKIP: {
     is(sprintf("%.0a", 1.9999999999999999999), "0x1p+1");
 }
 
     is(sprintf("%.0a", 1.9999999999999999999), "0x1p+1");
 }
 
+# quadmath tests for rt.perl.org #128843
+SKIP: {
+    skip "need quadmath", 7, unless $Config{usequadmath};
+
+    is(sprintf("%a", eval '0x1p-16382'), '0x1p-16382');  # last normal
+
+    local $SIG{__WARN__} = sub {
+        die "$0: $_[0]" unless $_[0] =~ /exponent underflow/;
+    };
+
+    is(sprintf("%a", eval '0x1p-16383'), '0x1p-16383');
+    is(sprintf("%a", eval '0x1p-16384'), '0x1p-16384');
+
+    is(sprintf("%a", eval '0x1p-16491'), '0x1p-16491');
+    is(sprintf("%a", eval '0x1p-16492'), '0x1p-16492');
+    is(sprintf("%a", eval '0x1p-16493'), '0x1p-16493'); # last denormal
+
+    is(sprintf("%a", eval '0x1p-16494'), '0x1p-16494'); # underflow
+}
+
 done_testing();
 done_testing();