]> Cypherpunks repositories - gostls13.git/commitdiff
go/types, types2: fix Hilbert test for stand-alone run
authorRobert Griesemer <gri@golang.org>
Tue, 13 Jun 2023 20:43:21 +0000 (13:43 -0700)
committerGopher Robot <gobot@golang.org>
Tue, 13 Jun 2023 21:00:12 +0000 (21:00 +0000)
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>
src/cmd/compile/internal/types2/hilbert_test.go
src/go/types/generate_test.go
src/go/types/hilbert_test.go

index 5b2b08782080d63b916358412cdd5cc4d11e6d5d..df8a3e7d78af57e4a384838a17bd5bbca4055cbb 100644 (file)
@@ -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)
 }
 
index 6a8343c615355c6539a3d5fcba6785f7606c2ed6..05a848be31d9cd968950d77012fc657b002944e7 100644 (file)
@@ -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)
index f5304224929464ad29f436dd69a886331b32fc28..434d78f929c63d0669797dc014501e440c48546c 100644 (file)
@@ -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)
 }