From: Ian Lance Taylor Date: Thu, 1 Feb 2018 04:40:34 +0000 (-0800) Subject: math: test for pos/neg zero return of Ceil/Floor/Trunc X-Git-Tag: go1.12beta1~1358 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=1ae2eed0b22023cc06ad7f1a82d2df2b6877b14b;p=gostls13.git math: test for pos/neg zero return of Ceil/Floor/Trunc Ceil and Trunc of -0.2 return -0, not +0, but we didn't test that. Updates #23647 Change-Id: Idbd4699376abfb4ca93f16c73c114d610d86a9f2 Reviewed-on: https://go-review.googlesource.com/91335 Run-TryBot: Ian Lance Taylor Reviewed-by: Brad Fitzpatrick TryBot-Result: Gobot Gobot --- diff --git a/src/math/all_test.go b/src/math/all_test.go index bcc20a3917..00f2058ea6 100644 --- a/src/math/all_test.go +++ b/src/math/all_test.go @@ -128,7 +128,7 @@ var cbrt = []float64{ var ceil = []float64{ 5.0000000000000000e+00, 8.0000000000000000e+00, - 0.0000000000000000e+00, + Copysign(0, -1), -5.0000000000000000e+00, 1.0000000000000000e+01, 3.0000000000000000e+00, @@ -644,7 +644,7 @@ var tanh = []float64{ var trunc = []float64{ 4.0000000000000000e+00, 7.0000000000000000e+00, - -0.0000000000000000e+00, + Copysign(0, -1), -5.0000000000000000e+00, 9.0000000000000000e+00, 2.0000000000000000e+00, @@ -2158,7 +2158,7 @@ func TestCbrt(t *testing.T) { func TestCeil(t *testing.T) { for i := 0; i < len(vf); i++ { - if f := Ceil(vf[i]); ceil[i] != f { + if f := Ceil(vf[i]); !alike(ceil[i], f) { t.Errorf("Ceil(%g) = %g, want %g", vf[i], f, ceil[i]) } } @@ -2385,7 +2385,7 @@ func TestDim(t *testing.T) { func TestFloor(t *testing.T) { for i := 0; i < len(vf); i++ { - if f := Floor(vf[i]); floor[i] != f { + if f := Floor(vf[i]); !alike(floor[i], f) { t.Errorf("Floor(%g) = %g, want %g", vf[i], f, floor[i]) } } @@ -2916,7 +2916,7 @@ func TestTanh(t *testing.T) { func TestTrunc(t *testing.T) { for i := 0; i < len(vf); i++ { - if f := Trunc(vf[i]); trunc[i] != f { + if f := Trunc(vf[i]); !alike(trunc[i], f) { t.Errorf("Trunc(%g) = %g, want %g", vf[i], f, trunc[i]) } }