Fix order of jn() arguments in error message
[libc-test.git] / src / math / y0.c
blob6684822e90da6e7e08f98953ca97ebb82f9ca974
1 #define _BSD_SOURCE 1
2 #define _XOPEN_SOURCE 700
3 #include <stdint.h>
4 #include <stdio.h>
5 #include "mtest.h"
7 static struct d_d t[] = {
8 #include "sanity/y0.h"
9 #include "special/y0.h"
13 int main(void)
15 #pragma STDC FENV_ACCESS ON
16 double y;
17 float d;
18 int e, i, err = 0;
19 struct d_d *p;
21 for (i = 0; i < sizeof t/sizeof *t; i++) {
22 p = t + i;
24 if (p->r < 0)
25 continue;
26 fesetround(p->r);
27 feclearexcept(FE_ALL_EXCEPT);
28 y = y0(p->x);
29 e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW);
31 if (!checkexcept(e, p->e, p->r)) {
32 printf("%s:%d: bad fp exception: %s y0(%a)=%a, want %s",
33 p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e));
34 printf(" got %s\n", estr(e));
35 err++;
37 d = ulperr(y, p->y, p->dy);
38 if ((!(p->x < 0) && !checkulp(d, p->r)) || (p->x < 0 && !isnan(y) && y != -inf)) {
39 // printf("%s:%d: %s y0(%a) want %a got %a ulperr %.3f = %a + %a\n",
40 // p->file, p->line, rstr(p->r), p->x, p->y, y, d, d-p->dy, p->dy);
41 err++;
42 // TODO: avoid spamming the output
43 printf(__FILE__ ": known to be broken near zeros\n");
44 break;
47 return !!err;