bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: getpayload* tests: Don't assume that '-' works as expected on NaN


From: Bruno Haible
Subject: Re: getpayload* tests: Don't assume that '-' works as expected on NaN
Date: Fri, 19 Apr 2024 17:29:04 +0200

I wrote:
> The patch below fixes the failures, by introducing a specific function, rather
> than unary minus, for negating the sign of NaNs.

This function should also be used for the getpayload* tests (although this has
not caused a test failure, because getpayload (- x) == getpayload (x)).


2024-04-19  Bruno Haible  <bruno@clisp.org>

        getpayload* tests: Don't assume that '-' works as expected on NaN.
        * tests/test-getpayload.c: Include signed-nan.h.
        (main): Use minus_NaNd.
        * tests/test-getpayloadf.c: Include signed-nan.h.
        (main): Use minus_NaNf.
        * tests/test-getpayloadl.c: Include signed-nan.h.
        (main): Use minus_NaNl.
        * modules/getpayload-tests (Depends-on): Add signed-nan.
        * modules/getpayloadf-tests (Depends-on): Likewise.
        * modules/getpayloadl-tests (Depends-on): Likewise.

diff --git a/modules/getpayload-tests b/modules/getpayload-tests
index d56192d63b..dcc27371fb 100644
--- a/modules/getpayload-tests
+++ b/modules/getpayload-tests
@@ -8,6 +8,7 @@ tests/macros.h
 Depends-on:
 setpayload
 setpayloadsig
+signed-nan
 signed-snan
 
 configure.ac:
diff --git a/modules/getpayloadf-tests b/modules/getpayloadf-tests
index 1901fc43f9..f1b0217600 100644
--- a/modules/getpayloadf-tests
+++ b/modules/getpayloadf-tests
@@ -8,6 +8,7 @@ tests/macros.h
 Depends-on:
 setpayloadf
 setpayloadsigf
+signed-nan
 signed-snan
 
 configure.ac:
diff --git a/modules/getpayloadl-tests b/modules/getpayloadl-tests
index 02433a206d..fc508e797b 100644
--- a/modules/getpayloadl-tests
+++ b/modules/getpayloadl-tests
@@ -8,6 +8,7 @@ tests/macros.h
 Depends-on:
 setpayloadl
 setpayloadsigl
+signed-nan
 signed-snan
 
 configure.ac:
diff --git a/tests/test-getpayload.c b/tests/test-getpayload.c
index a6d9d940bd..54d4e77612 100644
--- a/tests/test-getpayload.c
+++ b/tests/test-getpayload.c
@@ -24,6 +24,7 @@ SIGNATURE_CHECK (getpayload, double, (const double *));
 
 #include "minus-zero.h"
 #include "infinity.h"
+#include "signed-nan.h"
 #include "signed-snan.h"
 #include "macros.h"
 
@@ -72,7 +73,7 @@ main ()
         ret = getpayload (&arg);
         ASSERT (ret == p);
         /* Test quiet NaNs with sign bit == 1.  */
-        arg = - arg;
+        arg = minus_NaNd (arg);
         ret = getpayload (&arg);
         ASSERT (ret == p);
       }
diff --git a/tests/test-getpayloadf.c b/tests/test-getpayloadf.c
index f0ec047235..48832763e3 100644
--- a/tests/test-getpayloadf.c
+++ b/tests/test-getpayloadf.c
@@ -24,6 +24,7 @@ SIGNATURE_CHECK (getpayloadf, float, (const float *));
 
 #include "minus-zero.h"
 #include "infinity.h"
+#include "signed-nan.h"
 #include "signed-snan.h"
 #include "macros.h"
 
@@ -72,7 +73,7 @@ main ()
         ret = getpayloadf (&arg);
         ASSERT (ret == p);
         /* Test quiet NaNs with sign bit == 1.  */
-        arg = - arg;
+        arg = minus_NaNf (arg);
         ret = getpayloadf (&arg);
         ASSERT (ret == p);
       }
diff --git a/tests/test-getpayloadl.c b/tests/test-getpayloadl.c
index 4aaa7c5c0c..12ff6dea8f 100644
--- a/tests/test-getpayloadl.c
+++ b/tests/test-getpayloadl.c
@@ -24,6 +24,7 @@ SIGNATURE_CHECK (getpayloadl, long double, (const long double 
*));
 
 #include "minus-zero.h"
 #include "infinity.h"
+#include "signed-nan.h"
 #include "signed-snan.h"
 #include "macros.h"
 
@@ -79,7 +80,7 @@ main ()
         ret = getpayloadl (&arg);
         ASSERT (ret == p);
         /* Test quiet NaNs with sign bit == 1.  */
-        arg = - arg;
+        arg = minus_NaNl (arg);
         ret = getpayloadl (&arg);
         ASSERT (ret == p);
       }






reply via email to

[Prev in Thread] Current Thread [Next in Thread]