]> Cypherpunks repositories - gostls13.git/commitdiff
math: test large negative values as args for trig functions
authorKeith Randall <khr@golang.org>
Fri, 14 Jul 2023 15:34:39 +0000 (08:34 -0700)
committerKeith Randall <khr@google.com>
Mon, 17 Jul 2023 21:05:34 +0000 (21:05 +0000)
Sin/Tan are odd, Cos is even, so it is easy to compute the correct
result from the positive argument case.

Change-Id: If851d00fc7f515ece8199cf56d21186ced51e94f
Reviewed-on: https://go-review.googlesource.com/c/go/+/509815
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Srinivas Pokala <Pokala.Srinivas@ibm.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Keith Randall <khr@google.com>
src/math/huge_test.go

index bc28c6ff693a55855ecee6fc124b224f8a057026..568b0c85eb1da9f69deda803a565ae6afe56b678 100644 (file)
@@ -81,6 +81,10 @@ func TestHugeCos(t *testing.T) {
                if !close(f1, f2) {
                        t.Errorf("Cos(%g) = %g, want %g", trigHuge[i], f2, f1)
                }
+               f3 := Cos(-trigHuge[i])
+               if !close(f1, f3) {
+                       t.Errorf("Cos(%g) = %g, want %g", -trigHuge[i], f3, f1)
+               }
        }
 }
 
@@ -91,6 +95,10 @@ func TestHugeSin(t *testing.T) {
                if !close(f1, f2) {
                        t.Errorf("Sin(%g) = %g, want %g", trigHuge[i], f2, f1)
                }
+               f3 := Sin(-trigHuge[i])
+               if !close(-f1, f3) {
+                       t.Errorf("Sin(%g) = %g, want %g", -trigHuge[i], f3, -f1)
+               }
        }
 }
 
@@ -101,6 +109,10 @@ func TestHugeSinCos(t *testing.T) {
                if !close(f1, f2) || !close(g1, g2) {
                        t.Errorf("Sincos(%g) = %g, %g, want %g, %g", trigHuge[i], f2, g2, f1, g1)
                }
+               f3, g3 := Sincos(-trigHuge[i])
+               if !close(-f1, f3) || !close(g1, g3) {
+                       t.Errorf("Sincos(%g) = %g, %g, want %g, %g", -trigHuge[i], f3, g3, -f1, g1)
+               }
        }
 }
 
@@ -111,5 +123,9 @@ func TestHugeTan(t *testing.T) {
                if !close(f1, f2) {
                        t.Errorf("Tan(%g) = %g, want %g", trigHuge[i], f2, f1)
                }
+               f3 := Tan(-trigHuge[i])
+               if !close(-f1, f3) {
+                       t.Errorf("Tan(%g) = %g, want %g", -trigHuge[i], f3, -f1)
+               }
        }
 }