Restore #include "progname.h"
[gnulib.git] / tests / test-frexp.c
index 3c2ea80..9ce989b 100644 (file)
 #include <math.h>
 
 #include <float.h>
+#include <stdio.h>
 #include <stdlib.h>
 
-#define ASSERT(expr) if (!(expr)) abort ();
+#include "isnan.h"
+
+#define ASSERT(expr) \
+  do                                                                        \
+    {                                                                       \
+      if (!(expr))                                                          \
+        {                                                                   \
+          fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
+          abort ();                                                         \
+        }                                                                   \
+    }                                                                       \
+  while (0)
+
+/* The Compaq (ex-DEC) C 6.4 compiler chokes on the expression 0.0 / 0.0.  */
+#ifdef __DECC
+static double
+NaN ()
+{
+  static double zero = 0.0;
+  return zero / zero;
+}
+#else
+# define NaN() (0.0 / 0.0)
+#endif
 
 static double
 my_ldexp (double x, int d)
@@ -50,9 +74,9 @@ main ()
   { /* NaN.  */
     int exp = -9999;
     double mantissa;
-    x = 0.0 / 0.0;
+    x = NaN ();
     mantissa = frexp (x, &exp);
-    ASSERT (mantissa != mantissa);
+    ASSERT (isnan (mantissa));
   }
 
   { /* Positive infinity.  */
@@ -78,6 +102,7 @@ main ()
     mantissa = frexp (x, &exp);
     ASSERT (exp == 0);
     ASSERT (mantissa == x);
+    ASSERT (!signbit (mantissa));
   }
 
   { /* Negative zero.  */
@@ -87,6 +112,7 @@ main ()
     mantissa = frexp (x, &exp);
     ASSERT (exp == 0);
     ASSERT (mantissa == x);
+    ASSERT (signbit (mantissa));
   }
 
   for (i = 1, x = 1.0; i <= DBL_MAX_EXP; i++, x *= 2.0)