mirror of
https://github.com/golang/go
synced 2024-11-21 15:14:43 -07:00
test: override gcc bug when preparing complex divide tables
R=iant CC=golang-dev https://golang.org/cl/1666048
This commit is contained in:
parent
93f614ff86
commit
47c85ec97a
@ -35,7 +35,15 @@ fmt(double g)
|
||||
if(strcmp(p, "-0") == 0)
|
||||
strcpy(p, "negzero");
|
||||
return p;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
iscnan(double complex d)
|
||||
{
|
||||
return !isinf(creal(d)) && !isinf(cimag(d)) && (isnan(creal(d)) || isnan(cimag(d)));
|
||||
}
|
||||
|
||||
double complex zero; // attempt to hide zero division from gcc
|
||||
|
||||
int
|
||||
main(void)
|
||||
@ -54,7 +62,20 @@ main(void)
|
||||
n = f[i] + f[j]*I;
|
||||
d = f[k] + f[l]*I;
|
||||
q = n/d;
|
||||
printf("\tTest{cmplx(%s, %s), cmplx(%s, %s), cmplx(%s, %s)},\n", fmt(creal(n)), fmt(cimag(n)), fmt(creal(d)), fmt(cimag(d)), fmt(creal(q)), fmt(cimag(q)));
|
||||
|
||||
// BUG FIX.
|
||||
// Gcc gets the wrong answer for NaN/0 unless both sides are NaN.
|
||||
// That is, it treats (NaN+NaN*I)/0 = NaN+NaN*I (a complex NaN)
|
||||
// but it then computes (1+NaN*I)/0 = Inf+NaN*I (a complex infinity).
|
||||
// Since both numerators are complex NaNs, it seems that the
|
||||
// results should agree in kind. Override the gcc computation in this case.
|
||||
if(iscnan(n) && d == 0)
|
||||
q = (NAN+NAN*I) / zero;
|
||||
|
||||
printf("\tTest{cmplx(%s, %s), cmplx(%s, %s), cmplx(%s, %s)},\n",
|
||||
fmt(creal(n)), fmt(cimag(n)),
|
||||
fmt(creal(d)), fmt(cimag(d)),
|
||||
fmt(creal(q)), fmt(cimag(q)));
|
||||
}
|
||||
printf("}\n");
|
||||
return 0;
|
||||
|
@ -1,6 +1,7 @@
|
||||
// # generated by cmplxdivide.c
|
||||
|
||||
package main
|
||||
|
||||
var tests = []Test{
|
||||
Test{cmplx(0, 0), cmplx(0, 0), cmplx(nan, nan)},
|
||||
Test{cmplx(0, 0), cmplx(0, 1), cmplx(0, 0)},
|
||||
@ -541,7 +542,7 @@ var tests = []Test{
|
||||
Test{cmplx(1, 2), cmplx(-inf, nan), cmplx(negzero, negzero)},
|
||||
Test{cmplx(1, 2), cmplx(-inf, inf), cmplx(0, negzero)},
|
||||
Test{cmplx(1, 2), cmplx(-inf, -inf), cmplx(negzero, negzero)},
|
||||
Test{cmplx(1, nan), cmplx(0, 0), cmplx(inf, nan)},
|
||||
Test{cmplx(1, nan), cmplx(0, 0), cmplx(nan, nan)},
|
||||
Test{cmplx(1, nan), cmplx(0, 1), cmplx(nan, nan)},
|
||||
Test{cmplx(1, nan), cmplx(0, -1), cmplx(nan, nan)},
|
||||
Test{cmplx(1, nan), cmplx(0, 2), cmplx(nan, nan)},
|
||||
@ -884,7 +885,7 @@ var tests = []Test{
|
||||
Test{cmplx(-1, 2), cmplx(-inf, nan), cmplx(0, negzero)},
|
||||
Test{cmplx(-1, 2), cmplx(-inf, inf), cmplx(0, negzero)},
|
||||
Test{cmplx(-1, 2), cmplx(-inf, -inf), cmplx(negzero, negzero)},
|
||||
Test{cmplx(-1, nan), cmplx(0, 0), cmplx(-inf, nan)},
|
||||
Test{cmplx(-1, nan), cmplx(0, 0), cmplx(nan, nan)},
|
||||
Test{cmplx(-1, nan), cmplx(0, 1), cmplx(nan, nan)},
|
||||
Test{cmplx(-1, nan), cmplx(0, -1), cmplx(nan, nan)},
|
||||
Test{cmplx(-1, nan), cmplx(0, 2), cmplx(nan, nan)},
|
||||
@ -1227,7 +1228,7 @@ var tests = []Test{
|
||||
Test{cmplx(2, 2), cmplx(-inf, nan), cmplx(negzero, negzero)},
|
||||
Test{cmplx(2, 2), cmplx(-inf, inf), cmplx(0, negzero)},
|
||||
Test{cmplx(2, 2), cmplx(-inf, -inf), cmplx(negzero, 0)},
|
||||
Test{cmplx(2, nan), cmplx(0, 0), cmplx(inf, nan)},
|
||||
Test{cmplx(2, nan), cmplx(0, 0), cmplx(nan, nan)},
|
||||
Test{cmplx(2, nan), cmplx(0, 1), cmplx(nan, nan)},
|
||||
Test{cmplx(2, nan), cmplx(0, -1), cmplx(nan, nan)},
|
||||
Test{cmplx(2, nan), cmplx(0, 2), cmplx(nan, nan)},
|
||||
@ -1423,7 +1424,7 @@ var tests = []Test{
|
||||
Test{cmplx(nan, 0), cmplx(-inf, nan), cmplx(nan, nan)},
|
||||
Test{cmplx(nan, 0), cmplx(-inf, inf), cmplx(nan, nan)},
|
||||
Test{cmplx(nan, 0), cmplx(-inf, -inf), cmplx(nan, nan)},
|
||||
Test{cmplx(nan, 1), cmplx(0, 0), cmplx(nan, inf)},
|
||||
Test{cmplx(nan, 1), cmplx(0, 0), cmplx(nan, nan)},
|
||||
Test{cmplx(nan, 1), cmplx(0, 1), cmplx(nan, nan)},
|
||||
Test{cmplx(nan, 1), cmplx(0, -1), cmplx(nan, nan)},
|
||||
Test{cmplx(nan, 1), cmplx(0, 2), cmplx(nan, nan)},
|
||||
@ -1472,7 +1473,7 @@ var tests = []Test{
|
||||
Test{cmplx(nan, 1), cmplx(-inf, nan), cmplx(nan, nan)},
|
||||
Test{cmplx(nan, 1), cmplx(-inf, inf), cmplx(nan, nan)},
|
||||
Test{cmplx(nan, 1), cmplx(-inf, -inf), cmplx(nan, nan)},
|
||||
Test{cmplx(nan, -1), cmplx(0, 0), cmplx(nan, -inf)},
|
||||
Test{cmplx(nan, -1), cmplx(0, 0), cmplx(nan, nan)},
|
||||
Test{cmplx(nan, -1), cmplx(0, 1), cmplx(nan, nan)},
|
||||
Test{cmplx(nan, -1), cmplx(0, -1), cmplx(nan, nan)},
|
||||
Test{cmplx(nan, -1), cmplx(0, 2), cmplx(nan, nan)},
|
||||
@ -1521,7 +1522,7 @@ var tests = []Test{
|
||||
Test{cmplx(nan, -1), cmplx(-inf, nan), cmplx(nan, nan)},
|
||||
Test{cmplx(nan, -1), cmplx(-inf, inf), cmplx(nan, nan)},
|
||||
Test{cmplx(nan, -1), cmplx(-inf, -inf), cmplx(nan, nan)},
|
||||
Test{cmplx(nan, 2), cmplx(0, 0), cmplx(nan, inf)},
|
||||
Test{cmplx(nan, 2), cmplx(0, 0), cmplx(nan, nan)},
|
||||
Test{cmplx(nan, 2), cmplx(0, 1), cmplx(nan, nan)},
|
||||
Test{cmplx(nan, 2), cmplx(0, -1), cmplx(nan, nan)},
|
||||
Test{cmplx(nan, 2), cmplx(0, 2), cmplx(nan, nan)},
|
||||
|
Loading…
Reference in New Issue
Block a user