From 72a1f1464fce63c33f53fbdf721d1822e94ff4ee Mon Sep 17 00:00:00 2001 From: Dan Kortschak Date: Tue, 19 Mar 2019 13:03:31 +1030 Subject: [PATCH] mat: fix test for changes in Go runtime See golang/go@2c423f063b137781a97a6a56998a2e3abffc4051. --- mat/dense_test.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mat/dense_test.go b/mat/dense_test.go index c30f7726..7f994041 100644 --- a/mat/dense_test.go +++ b/mat/dense_test.go @@ -8,6 +8,7 @@ import ( "fmt" "math" "reflect" + "strings" "testing" "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. temp.mat.Data = nil 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") } @@ -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. temp.mat.Data = nil 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") } @@ -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. temp.mat.Data = nil 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") } @@ -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. temp.mat.Data = nil 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") }