Skip to content

Commit 9b33543

Browse files
committed
math: test large negative values as args for trig functions
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 <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Srinivas Pokala <[email protected]> Reviewed-by: Robert Griesemer <[email protected]> Reviewed-by: Keith Randall <[email protected]>
1 parent 229cde5 commit 9b33543

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/math/huge_test.go

+16
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ func TestHugeCos(t *testing.T) {
8181
if !close(f1, f2) {
8282
t.Errorf("Cos(%g) = %g, want %g", trigHuge[i], f2, f1)
8383
}
84+
f3 := Cos(-trigHuge[i])
85+
if !close(f1, f3) {
86+
t.Errorf("Cos(%g) = %g, want %g", -trigHuge[i], f3, f1)
87+
}
8488
}
8589
}
8690

@@ -91,6 +95,10 @@ func TestHugeSin(t *testing.T) {
9195
if !close(f1, f2) {
9296
t.Errorf("Sin(%g) = %g, want %g", trigHuge[i], f2, f1)
9397
}
98+
f3 := Sin(-trigHuge[i])
99+
if !close(-f1, f3) {
100+
t.Errorf("Sin(%g) = %g, want %g", -trigHuge[i], f3, -f1)
101+
}
94102
}
95103
}
96104

@@ -101,6 +109,10 @@ func TestHugeSinCos(t *testing.T) {
101109
if !close(f1, f2) || !close(g1, g2) {
102110
t.Errorf("Sincos(%g) = %g, %g, want %g, %g", trigHuge[i], f2, g2, f1, g1)
103111
}
112+
f3, g3 := Sincos(-trigHuge[i])
113+
if !close(-f1, f3) || !close(g1, g3) {
114+
t.Errorf("Sincos(%g) = %g, %g, want %g, %g", -trigHuge[i], f3, g3, -f1, g1)
115+
}
104116
}
105117
}
106118

@@ -111,5 +123,9 @@ func TestHugeTan(t *testing.T) {
111123
if !close(f1, f2) {
112124
t.Errorf("Tan(%g) = %g, want %g", trigHuge[i], f2, f1)
113125
}
126+
f3 := Tan(-trigHuge[i])
127+
if !close(-f1, f3) {
128+
t.Errorf("Tan(%g) = %g, want %g", -trigHuge[i], f3, -f1)
129+
}
114130
}
115131
}

0 commit comments

Comments
 (0)