aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2023-06-13 13:43:21 -0700
committerGopher Robot <gobot@golang.org>2023-06-13 21:00:12 +0000
commitdac75b66754978a89eeb143e2b7cabb830409fd8 (patch)
tree7c30d677a99a3ee521cbe10ba1310f2e48c2c29e
parent9efa625d8425fd97381c80c948689c0eb0f76769 (diff)
downloadgo-dac75b66754978a89eeb143e2b7cabb830409fd8.tar.gz
go-dac75b66754978a89eeb143e2b7cabb830409fd8.zip
go/types, types2: fix Hilbert test for stand-alone run
When run as a stand-alone test (without other tests running before), the builtin function 'assert' (only available for testing) is missing. Make sure it's declared. This change only affects this test, when run stand-alone, as in: go test -run Hilbert Fixes #60774. Change-Id: Ib07d97ba2670b839e8ad11ef50d0e6581bb3d79d Reviewed-on: https://go-review.googlesource.com/c/go/+/502996 Auto-Submit: Robert Griesemer <gri@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Robert Griesemer <gri@google.com> Reviewed-by: Robert Findley <rfindley@google.com> Reviewed-by: Robert Griesemer <gri@google.com>
-rw-r--r--src/cmd/compile/internal/types2/hilbert_test.go3
-rw-r--r--src/go/types/generate_test.go2
-rw-r--r--src/go/types/hilbert_test.go3
3 files changed, 7 insertions, 1 deletions
diff --git a/src/cmd/compile/internal/types2/hilbert_test.go b/src/cmd/compile/internal/types2/hilbert_test.go
index 5b2b087820..df8a3e7d78 100644
--- a/src/cmd/compile/internal/types2/hilbert_test.go
+++ b/src/cmd/compile/internal/types2/hilbert_test.go
@@ -10,6 +10,8 @@ import (
"fmt"
"os"
"testing"
+
+ . "cmd/compile/internal/types2"
)
var (
@@ -25,6 +27,7 @@ func TestHilbert(t *testing.T) {
return
}
+ DefPredeclaredTestFuncs() // declare assert (used by code generated by verify)
mustTypecheck(string(src), nil, nil)
}
diff --git a/src/go/types/generate_test.go b/src/go/types/generate_test.go
index 6a8343c615..05a848be31 100644
--- a/src/go/types/generate_test.go
+++ b/src/go/types/generate_test.go
@@ -102,7 +102,7 @@ var filemap = map[string]action{
"context.go": nil,
"context_test.go": nil,
"gccgosizes.go": nil,
- "hilbert_test.go": nil,
+ "hilbert_test.go": func(f *ast.File) { renameImportPath(f, `"cmd/compile/internal/types2"`, `"go/types"`) },
"infer.go": func(f *ast.File) {
fixTokenPos(f)
fixInferSig(f)
diff --git a/src/go/types/hilbert_test.go b/src/go/types/hilbert_test.go
index f530422492..434d78f929 100644
--- a/src/go/types/hilbert_test.go
+++ b/src/go/types/hilbert_test.go
@@ -12,6 +12,8 @@ import (
"fmt"
"os"
"testing"
+
+ . "go/types"
)
var (
@@ -27,6 +29,7 @@ func TestHilbert(t *testing.T) {
return
}
+ DefPredeclaredTestFuncs() // declare assert (used by code generated by verify)
mustTypecheck(string(src), nil, nil)
}