floats: fix Same for NaN/N
MODIFY
floats/floats.go
floats/floats.go
@@ -706,7 +706,7 @@ func Same(s, t []float64) bool {
}
for i, v := range s {
w := t[i]
- if v != w && !math.IsNaN(v) && !math.IsNaN(w) {
+ if v != w && !(math.IsNaN(v) && math.IsNaN(w)) {
return false
}
}

MODIFY
floats/floats_test.go
floats/floats_test.go
@@ -1130,7 +1130,7 @@ func TestSame(t *testing.T) {
}
s1 = []float64{1, 2, math.NaN(), 4}
s2 = []float64{1, math.NaN(), 3, 4}
- if !Same(s1, s2) {
+ if Same(s1, s2) {
t.Errorf("Slices with unmatching NaN values returned as equal")
}
}

floats: fix Same for NaN/N