diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2018-01-10 13:17:50 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2018-01-10 13:17:50 +0000 |
commit | 29c0549779a4868788c8fc96c123a2b5c31195db (patch) | |
tree | 12a658cc6032eb30f83bb7f57a45f2c6eba91e96 /tests/tlgamma.c | |
parent | 43a1b9a5621ec7e553669ade0d99729d71502b34 (diff) | |
download | mpfr-29c0549779a4868788c8fc96c123a2b5c31195db.tar.gz |
[tests/tlgamma.c] Added a test case for a bug found from the tgeneric
change done in r12088.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@12089 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests/tlgamma.c')
-rw-r--r-- | tests/tlgamma.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/tlgamma.c b/tests/tlgamma.c index 20cb37ab6..88e74f109 100644 --- a/tests/tlgamma.c +++ b/tests/tlgamma.c @@ -405,12 +405,52 @@ tcc_bug20160606 (void) mpfr_clear (y); } +/* With r12088, mpfr_lgamma is much too slow with a reduced emax that + yields an overflow, even though this case is easier. In practice, + this test will hang. */ +static void +bug20180110 (void) +{ + mpfr_exp_t emax, e; + mpfr_t x, y, z; + int i, sign; + + emax = mpfr_get_emax (); + + mpfr_init2 (x, 2); + mpfr_inits2 (64, y, z, (mpfr_ptr) 0); + + for (i = 10; i <= 30; i++) + { + mpfr_set_si_2exp (x, -1, -(1L << i), MPFR_RNDN); /* -2^(-2^i) */ + mpfr_lgamma (y, &sign, x, MPFR_RNDZ); + e = mpfr_get_exp (y); + mpfr_set_emax (e - 1); + mpfr_lgamma (y, &sign, x, MPFR_RNDZ); + mpfr_set_inf (z, 1); + mpfr_nextbelow (z); + mpfr_set_emax (emax); + if (! mpfr_equal_p (y, z)) + { + printf ("Error in bug20180110 for i = %d:\n", i); + printf ("Expected "); + mpfr_dump (z); + printf ("Got "); + mpfr_dump (y); + exit (1); + } + } + + mpfr_clears (x, y, z, (mpfr_ptr) 0); +} + int main (void) { tests_start_mpfr (); tcc_bug20160606 (); + bug20180110 (); special (); test_generic (MPFR_PREC_MIN, 100, 2); |