add exp10l test case (1e-15)
[libc-test] / src / math / lgammal_r.c
index bfb8efc..2f4927e 100644 (file)
@@ -1,19 +1,23 @@
+#define _GNU_SOURCE 1
 #include <stdint.h>
 #include <stdio.h>
-#include "util.h"
+#include "mtest.h"
 
 static struct l_li t[] = {
 #if LDBL_MANT_DIG == 53
-#include "sanity/lgammal_r.h"
+#include "sanity/lgamma_r.h"
+#include "special/lgamma_r.h"
 
 #elif LDBL_MANT_DIG == 64
 #include "sanity/lgammal_r.h"
+#include "special/lgammal_r.h"
 
 #endif
 };
 
 int main(void)
 {
+       #pragma STDC FENV_ACCESS ON
        int yi;
        long double y;
        float d;
@@ -22,9 +26,14 @@ int main(void)
 
        for (i = 0; i < sizeof t/sizeof *t; i++) {
                p = t + i;
-               setupfenv(p->r);
+
+               if (p->r < 0)
+                       continue;
+               fesetround(p->r);
+               feclearexcept(FE_ALL_EXCEPT);
                y = lgammal_r(p->x, &yi);
-               e = getexcept();
+               e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW);
+
                if (!checkexcept(e, p->e, p->r)) {
                        printf("%s:%d: bad fp exception: %s lgammal_r(%La)=%La,%lld, want %s",
                                p->file, p->line, rstr(p->r), p->x, p->y, p->i, estr(p->e));
@@ -32,7 +41,7 @@ int main(void)
                        err++;
                }
                d = ulperrl(y, p->y, p->dy);
-               if (!checkulp(d, p->r) || yi != p->i) {
+               if (!checkulp(d, p->r) || (!isnan(p->x) && p->x!=-inf && !(p->e&DIVBYZERO) && yi != p->i)) {
                        printf("%s:%d: %s lgammal_r(%La) want %La,%lld got %La,%d ulperr %.3f = %a + %a\n",
                                p->file, p->line, rstr(p->r), p->x, p->y, p->i, y, yi, d, d-p->dy, p->dy);
                        err++;