mat: fix test for changes in Go runtime

See golang/go@2c423f063b.
This commit is contained in:
Dan Kortschak
2019-03-19 13:03:31 +10:30
parent 9182d211c6
commit 72a1f1464f

View File

@@ -8,6 +8,7 @@ import (
"fmt" "fmt"
"math" "math"
"reflect" "reflect"
"strings"
"testing" "testing"
"golang.org/x/exp/rand" "golang.org/x/exp/rand"
@@ -518,7 +519,7 @@ func TestDenseAdd(t *testing.T) {
// These probably warrant a better check and failure. They should never happen in the wild though. // These probably warrant a better check and failure. They should never happen in the wild though.
temp.mat.Data = nil temp.mat.Data = nil
panicked, message := panics(func() { temp.Add(a, b) }) panicked, message := panics(func() { temp.Add(a, b) })
if !panicked || message != "runtime error: index out of range" { if !panicked || !strings.HasPrefix(message, "runtime error: index out of range") {
t.Error("exected runtime panic for nil data slice") t.Error("exected runtime panic for nil data slice")
} }
@@ -605,7 +606,7 @@ func TestDenseSub(t *testing.T) {
// These probably warrant a better check and failure. They should never happen in the wild though. // These probably warrant a better check and failure. They should never happen in the wild though.
temp.mat.Data = nil temp.mat.Data = nil
panicked, message := panics(func() { temp.Sub(a, b) }) panicked, message := panics(func() { temp.Sub(a, b) })
if !panicked || message != "runtime error: index out of range" { if !panicked || !strings.HasPrefix(message, "runtime error: index out of range") {
t.Error("exected runtime panic for nil data slice") t.Error("exected runtime panic for nil data slice")
} }
@@ -692,7 +693,7 @@ func TestDenseMulElem(t *testing.T) {
// These probably warrant a better check and failure. They should never happen in the wild though. // These probably warrant a better check and failure. They should never happen in the wild though.
temp.mat.Data = nil temp.mat.Data = nil
panicked, message := panics(func() { temp.MulElem(a, b) }) panicked, message := panics(func() { temp.MulElem(a, b) })
if !panicked || message != "runtime error: index out of range" { if !panicked || !strings.HasPrefix(message, "runtime error: index out of range") {
t.Error("exected runtime panic for nil data slice") t.Error("exected runtime panic for nil data slice")
} }
@@ -795,7 +796,7 @@ func TestDenseDivElem(t *testing.T) {
// These probably warrant a better check and failure. They should never happen in the wild though. // These probably warrant a better check and failure. They should never happen in the wild though.
temp.mat.Data = nil temp.mat.Data = nil
panicked, message := panics(func() { temp.DivElem(a, b) }) panicked, message := panics(func() { temp.DivElem(a, b) })
if !panicked || message != "runtime error: index out of range" { if !panicked || !strings.HasPrefix(message, "runtime error: index out of range") {
t.Error("exected runtime panic for nil data slice") t.Error("exected runtime panic for nil data slice")
} }