summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2017-05-19 13:45:10 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2017-05-19 13:45:10 +0000
commitcd6d443a66f0ac8a9e7b46a4ce5adfdcc0c399c8 (patch)
tree046a6e58bde0755b86f1a66ee3d8cd995390108c
parentf19ddeb2b18e1483ae3f9e5570e3ed9380d339be (diff)
downloadmpfr-cd6d443a66f0ac8a9e7b46a4ce5adfdcc0c399c8.tar.gz
[tests] Got rid of MPFR_TESTS_EXCEPTIONS (added in r11489 and above),
which is redundant with MPFR_TESTS_DIVBYZERO and MPFR_ERRDIVZERO. The code related to these exception is now like r11488 (see the output of "svn diff -r11488"), but keeping the following changes: * Missing !defined(MPFR_ERRDIVZERO) tests added in r11498,11499. * In tests.c: - code related to traps (macro MPFR_RAISE_EXCEPTIONS, which will be renamed); - more detailed output about which FP exceptions occurred; - removal of "#ifdef MPFR_ERRDIVZERO" (as in r11493), as this is better with Automake 1.13+ (required by MPFR since r9375). Note: EXCEPTIONS_FLAG renamed to FPE_FLAGS, since EXCEPTIONS_FLAG is reserved by ISO C when <errno.h> is included. git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@11504 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r--tests/tcmp_d.c2
-rw-r--r--tests/tcmp_ld.c2
-rw-r--r--tests/td_div.c3
-rw-r--r--tests/tests.c45
-rw-r--r--tests/tget_d.c8
-rw-r--r--tests/tget_d_2exp.c2
-rw-r--r--tests/tget_flt.c8
-rw-r--r--tests/tget_ld_2exp.c2
-rw-r--r--tests/tget_set_d64.c4
-rw-r--r--tests/tset_d.c4
-rw-r--r--tests/tset_float128.c6
-rw-r--r--tests/tset_ld.c8
12 files changed, 42 insertions, 52 deletions
diff --git a/tests/tcmp_d.c b/tests/tcmp_d.c
index 75b233ae1..00fc5e987 100644
--- a/tests/tcmp_d.c
+++ b/tests/tcmp_d.c
@@ -80,7 +80,7 @@ main (void)
}
set_emin (emin);
-#if !defined(MPFR_ERRDIVZERO) && !defined(MPFR_TESTS_EXCEPTIONS)
+#if !defined(MPFR_ERRDIVZERO)
/* Check NAN */
{
int c;
diff --git a/tests/tcmp_ld.c b/tests/tcmp_ld.c
index 89ef2c834..dbe6957db 100644
--- a/tests/tcmp_ld.c
+++ b/tests/tcmp_ld.c
@@ -82,7 +82,7 @@ main (void)
}
set_emin (emin);
-#if !defined(MPFR_ERRDIVZERO) && !defined(MPFR_TESTS_EXCEPTIONS)
+#if !defined(MPFR_ERRDIVZERO)
/* Check NAN */
{
int c;
diff --git a/tests/td_div.c b/tests/td_div.c
index c15ebf26a..e3ca3e434 100644
--- a/tests/td_div.c
+++ b/tests/td_div.c
@@ -59,7 +59,7 @@ check_nans (void)
MPFR_ASSERTN (mpfr_zero_p (y));
MPFR_ASSERTN (MPFR_IS_NEG (y));
-#if !defined(MPFR_ERRDIVZERO) && !defined(MPFR_TESTS_EXCEPTIONS)
+#if !defined(MPFR_ERRDIVZERO)
/* 1.0 / 0 == +inf */
mpfr_set_ui (x, 0, MPFR_RNDN);
@@ -136,6 +136,7 @@ check_nans (void)
MPFR_ASSERTN (__gmpfr_flags == 0);
MPFR_ASSERTN (mpfr_inf_p (y));
MPFR_ASSERTN (MPFR_IS_POS (y));
+
#endif
mpfr_clear (x);
diff --git a/tests/tests.c b/tests/tests.c
index 6639dc95a..205537a6f 100644
--- a/tests/tests.c
+++ b/tests/tests.c
@@ -31,10 +31,10 @@ http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
#include <locale.h>
#endif
-#if defined(MPFR_TESTS_DIVBYZERO) || defined(MPFR_TESTS_EXCEPTIONS)
-#ifdef MPFR_RAISE_EXCEPTIONS
-#define _GNU_SOURCE /* for feenableexcept */
-#endif
+#ifdef MPFR_TESTS_DIVBYZERO
+# ifdef MPFR_RAISE_EXCEPTIONS
+# define _GNU_SOURCE /* for feenableexcept */
+# endif
# include <fenv.h>
#endif
@@ -243,7 +243,7 @@ test_version (void)
for mpfr_xxx_d functions. Same for overflow. Thus we only check for
the division-by-zero and invalid exceptions, which should not occur
inside MPFR. */
-#define EXCEPTIONS_FLAG (FE_DIVBYZERO | FE_INVALID)
+#define FPE_FLAGS (FE_DIVBYZERO | FE_INVALID)
void
tests_start_mpfr (void)
@@ -264,13 +264,13 @@ tests_start_mpfr (void)
set_fpu_prec ();
#endif
-#if defined(MPFR_TESTS_DIVBYZERO) || defined(MPFR_TESTS_EXCEPTIONS)
+#ifdef MPFR_TESTS_DIVBYZERO
/* Define to test the use of MPFR_ERRDIVZERO */
feclearexcept (FE_ALL_EXCEPT);
/* to raise exceptions as soon as they arise, use feenableexcept */
-#ifdef MPFR_RAISE_EXCEPTIONS
- feenableexcept (EXCEPTIONS_FLAG);
-#endif
+# ifdef MPFR_RAISE_EXCEPTIONS
+ feenableexcept (FPE_FLAGS);
+# endif
#endif
if (!tests_memory_disabled)
@@ -305,31 +305,20 @@ tests_end_mpfr (void)
if (!tests_memory_disabled)
tests_memory_end ();
-#if defined(MPFR_TESTS_DIVBYZERO) || defined(MPFR_TESTS_EXCEPTIONS)
- if (fetestexcept (EXCEPTIONS_FLAG))
+#ifdef MPFR_TESTS_DIVBYZERO
+ /* Define to test the use of MPFR_ERRDIVZERO */
+ if (fetestexcept (FPE_FLAGS))
{
+ /* With MPFR_ERRDIVZERO, such exceptions should never occur
+ because the purpose of defining MPFR_ERRDIVZERO is to avoid
+ all the FP divisions by 0. */
printf ("Some floating-point exception(s) occurred:");
if (fetestexcept (FE_DIVBYZERO))
- {
- /* With MPFR_ERRDIVZERO, this should never occur because
- the purpose of defining MPFR_ERRDIVZERO is to avoid all
- the FP divisions by 0. */
- printf (" DIVBYZERO");
- err = 1;
- }
+ printf (" DIVBYZERO"); /* e.g. from 1.0 / 0.0 to generate an inf */
if (fetestexcept (FE_INVALID))
- {
- /* With MPFR_ERRDIVZERO, this should never occur because
- the purpose of defining MPFR_ERRDIVZERO is to avoid all
- the FP divisions by 0.
- Note: FE_INVALID comes from 0.0 / 0.0, in particular. */
- printf (" INVALID");
- err = 1;
- }
+ printf (" INVALID"); /* e.g. from 0.0 / 0.0 to generate a NaN */
printf ("\n");
-#ifdef MPFR_TESTS_EXCEPTIONS
err = 1;
-#endif
}
#endif
diff --git a/tests/tget_d.c b/tests/tget_d.c
index 6dc552a03..618093dab 100644
--- a/tests/tget_d.c
+++ b/tests/tget_d.c
@@ -89,7 +89,7 @@ static void
check_inf_nan (void)
{
/* only if nans and infs are available */
-#if !defined(MPFR_ERRDIVZERO) && !defined(MPFR_TESTS_EXCEPTIONS)
+#if !defined(MPFR_ERRDIVZERO)
mpfr_t x;
double d;
@@ -139,7 +139,7 @@ check_max (void)
MPFR_ASSERTN(d == -DBL_MAX);
d = mpfr_get_d (u, MPFR_RNDU);
MPFR_ASSERTN(d == -DBL_MAX);
-#if !defined(MPFR_ERRDIVZERO) && !defined(MPFR_TESTS_EXCEPTIONS)
+#if !defined(MPFR_ERRDIVZERO)
d = mpfr_get_d (u, MPFR_RNDN);
MPFR_ASSERTN(DOUBLE_ISINF(d) && d < 0.0);
d = mpfr_get_d (u, MPFR_RNDD);
@@ -151,7 +151,7 @@ check_max (void)
MPFR_ASSERTN(d == DBL_MAX);
d = mpfr_get_d (u, MPFR_RNDD);
MPFR_ASSERTN(d == DBL_MAX);
-#if !defined(MPFR_ERRDIVZERO) && !defined(MPFR_TESTS_EXCEPTIONS)
+#if !defined(MPFR_ERRDIVZERO)
d = mpfr_get_d (u, MPFR_RNDN);
MPFR_ASSERTN(DOUBLE_ISINF(d) && d > 0.0);
d = mpfr_get_d (u, MPFR_RNDU);
@@ -185,7 +185,7 @@ check_min(void)
static void
check_get_d_2exp_inf_nan (void)
{
-#if !defined(MPFR_ERRDIVZERO) && !defined(MPFR_TESTS_EXCEPTIONS)
+#if !defined(MPFR_ERRDIVZERO)
double var_d;
long exp;
diff --git a/tests/tget_d_2exp.c b/tests/tget_d_2exp.c
index a7ebb330e..8cf6af5ff 100644
--- a/tests/tget_d_2exp.c
+++ b/tests/tget_d_2exp.c
@@ -78,7 +78,7 @@ check_round (void)
static void
check_inf_nan (void)
{
-#if !defined(MPFR_ERRDIVZERO) && !defined(MPFR_TESTS_EXCEPTIONS)
+#if !defined(MPFR_ERRDIVZERO)
mpfr_t x;
double d;
long exp;
diff --git a/tests/tget_flt.c b/tests/tget_flt.c
index 2e08d9aca..778cc6800 100644
--- a/tests/tget_flt.c
+++ b/tests/tget_flt.c
@@ -36,7 +36,7 @@ main (void)
tests_start_mpfr ();
-#if !defined(MPFR_ERRDIVZERO) && !defined(MPFR_TESTS_EXCEPTIONS)
+#if !defined(MPFR_ERRDIVZERO)
/* The definition of DBL_POS_INF involves a division by 0. This makes
"clang -O2 -fsanitize=undefined -fno-sanitize-recover" fail. */
infp = (float) DBL_POS_INF;
@@ -51,7 +51,7 @@ main (void)
mpfr_init2 (x, 24);
mpfr_init2 (y, 24);
-#if !defined(MPFR_ERRDIVZERO) && !defined(MPFR_TESTS_EXCEPTIONS)
+#if !defined(MPFR_ERRDIVZERO)
mpfr_set_nan (x);
f = mpfr_get_flt (x, MPFR_RNDN);
if (! DOUBLE_ISNAN (f))
@@ -320,7 +320,7 @@ main (void)
printf ("expected %.8e, got %.8e\n", g, f);
exit (1);
}
-#if !defined(MPFR_ERRDIVZERO) && !defined(MPFR_TESTS_EXCEPTIONS)
+#if !defined(MPFR_ERRDIVZERO)
f = mpfr_get_flt (x, MPFR_RNDN); /* 2^128 rounds to itself with extended
exponent range, we should get +Inf */
g = infp;
@@ -365,7 +365,7 @@ main (void)
printf ("expected %.8e, got %.8e\n", g, f);
exit (1);
}
-#if !defined(MPFR_ERRDIVZERO) && !defined(MPFR_TESTS_EXCEPTIONS)
+#if !defined(MPFR_ERRDIVZERO)
f = mpfr_get_flt (x, MPFR_RNDN); /* first round to 2^128 (even rule),
thus we should get +Inf */
g = infp;
diff --git a/tests/tget_ld_2exp.c b/tests/tget_ld_2exp.c
index 5ee1e8936..d1f0511a2 100644
--- a/tests/tget_ld_2exp.c
+++ b/tests/tget_ld_2exp.c
@@ -77,7 +77,7 @@ check_round (void)
static void
check_inf_nan (void)
{
-#if !defined(MPFR_ERRDIVZERO) && !defined(MPFR_TESTS_EXCEPTIONS)
+#if !defined(MPFR_ERRDIVZERO)
mpfr_t x;
double d;
long exp;
diff --git a/tests/tget_set_d64.c b/tests/tget_set_d64.c
index 03c20d20f..6f1203dc8 100644
--- a/tests/tget_set_d64.c
+++ b/tests/tget_set_d64.c
@@ -91,7 +91,7 @@ check_misc (void)
mpfr_init2 (x, 123);
mpfr_init2 (y, 123);
-#if !defined(MPFR_ERRDIVZERO) && !defined(MPFR_TESTS_EXCEPTIONS)
+#if !defined(MPFR_ERRDIVZERO)
mpfr_set_nan (x);
d = mpfr_get_decimal64 (x, MPFR_RNDZ);
mpfr_set_ui (x, 1, MPFR_RNDZ);
@@ -399,7 +399,7 @@ main (void)
check_misc ();
check_random ();
check_native ();
-#if !defined(MPFR_ERRDIVZERO) && !defined(MPFR_TESTS_EXCEPTIONS)
+#if !defined(MPFR_ERRDIVZERO)
check_overflow ();
#endif
check_tiny ();
diff --git a/tests/tset_d.c b/tests/tset_d.c
index 35fce372b..3da550788 100644
--- a/tests/tset_d.c
+++ b/tests/tset_d.c
@@ -63,7 +63,7 @@ main (int argc, char *argv[])
mpfr_init (x);
-#if !defined(MPFR_ERRDIVZERO) && !defined(MPFR_TESTS_EXCEPTIONS)
+#if !defined(MPFR_ERRDIVZERO)
mpfr_set_nan (x);
d = mpfr_get_d (x, MPFR_RNDN);
if (! DOUBLE_ISNAN (d))
@@ -105,7 +105,7 @@ main (int argc, char *argv[])
}
#endif /* HAVE_SIGNEDZ */
-#if !defined(MPFR_ERRDIVZERO) && !defined(MPFR_TESTS_EXCEPTIONS)
+#if !defined(MPFR_ERRDIVZERO)
mpfr_set_inf (x, 1);
d = mpfr_get_d (x, MPFR_RNDN);
mpfr_set_ui (x, 0, MPFR_RNDN);
diff --git a/tests/tset_float128.c b/tests/tset_float128.c
index d1a92bffe..7d6b0a7a5 100644
--- a/tests/tset_float128.c
+++ b/tests/tset_float128.c
@@ -40,7 +40,7 @@ check_special (void)
mpfr_init2 (x, 113);
-#if !defined(MPFR_ERRDIVZERO) && !defined(MPFR_TESTS_EXCEPTIONS)
+#if !defined(MPFR_ERRDIVZERO)
/* check NaN */
f = 0.0 / 0.0;
mpfr_set_float128 (x, f, MPFR_RNDN);
@@ -102,7 +102,7 @@ check_special (void)
printf ("Error in mpfr_get_float128(+0.0)\n");
exit (1);
}
-#if !defined(MPFR_ERRDIVZERO) && defined(HAVE_SIGNEDZ) && !defined(MPFR_TESTS_EXCEPTIONS)
+#if !defined(MPFR_ERRDIVZERO) && defined(HAVE_SIGNEDZ)
if (1 / f != 1 / 0.0) /* check the sign */
{
printf ("Error in mpfr_get_float128(+0.0)\n");
@@ -131,7 +131,7 @@ check_special (void)
printf ("Error in mpfr_get_float128(-0.0)\n");
exit (1);
}
-#if !defined(MPFR_ERRDIVZERO) && defined(HAVE_SIGNEDZ) && !defined(MPFR_TESTS_EXCEPTIONS)
+#if !defined(MPFR_ERRDIVZERO) && defined(HAVE_SIGNEDZ)
if (1 / f != 1 / -0.0) /* check the sign */
{
printf ("Error in mpfr_get_float128(-0.0)\n");
diff --git a/tests/tset_ld.c b/tests/tset_ld.c
index 4dac1dea8..d8431e3ce 100644
--- a/tests/tset_ld.c
+++ b/tests/tset_ld.c
@@ -73,7 +73,7 @@ print_binary (long double d, int flag)
return 0;
}
if (d < (long double) 0.0
-#if !defined(MPFR_ERRDIVZERO) && !defined(MPFR_TESTS_EXCEPTIONS)
+#if !defined(MPFR_ERRDIVZERO)
|| (d == (long double) 0.0 && (1.0 / (double) d < 0.0))
#endif
)
@@ -506,7 +506,7 @@ main (int argc, char *argv[])
mpfr_init2 (x, MPFR_LDBL_MANT_DIG + 64);
-#if !defined(MPFR_ERRDIVZERO) && !defined(MPFR_TESTS_EXCEPTIONS)
+#if !defined(MPFR_ERRDIVZERO)
/* check NaN */
mpfr_set_nan (x);
d = mpfr_get_ld (x, MPFR_RNDN);
@@ -532,7 +532,7 @@ main (int argc, char *argv[])
#endif
}
-#if !defined(MPFR_ERRDIVZERO) && !defined(MPFR_TESTS_EXCEPTIONS)
+#if !defined(MPFR_ERRDIVZERO)
/* check +Inf */
mpfr_set_inf (x, 1);
d = mpfr_get_ld (x, MPFR_RNDN);
@@ -625,7 +625,7 @@ main (int argc, char *argv[])
test_small ();
check_subnormal ();
-#if !defined(MPFR_ERRDIVZERO) && !defined(MPFR_TESTS_EXCEPTIONS)
+#if !defined(MPFR_ERRDIVZERO)
check_overflow ();
#endif