go/types/objectpath,internal/aliases: miscellaneous clean up of tests that set gotypesalias

* Fix default value test ("") for TestNewAlias.
* Updates references to 1.19 to 1.22.

Change-Id: I9c19621e820c90c265235afff863863d03f2d171
Reviewed-on: https://go-review.googlesource.com/c/tools/+/615696
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
This commit is contained in:
Tim King 2024-09-25 11:55:31 -07:00
Родитель 23e1af6910
Коммит 1c9ca8b8ba
2 изменённых файлов: 15 добавлений и 8 удалений

Просмотреть файл

@ -34,7 +34,7 @@ func TestPaths(t *testing.T) {
}
func testPaths(t *testing.T, gotypesalias int) {
// override default set by go1.19 in go.mod
// override default set by go1.22 in go.mod
t.Setenv("GODEBUG", fmt.Sprintf("gotypesalias=%d", gotypesalias))
const src = `

Просмотреть файл

@ -45,8 +45,8 @@ func TestNewAlias(t *testing.T) {
for _, godebug := range []string{
// The default gotypesalias value follows the x/tools/go.mod version
// The go.mod is at 1.19 so the default is gotypesalias=0.
// "", // Use the default GODEBUG value.
// The go.mod is at 1.22 so the default is gotypesalias=0.
"", // Use the default GODEBUG value (off).
"gotypesalias=0",
"gotypesalias=1",
} {
@ -67,10 +67,14 @@ func TestNewAlias(t *testing.T) {
t.Errorf("Expected Unalias(A)==%q. got %q", want, got)
}
if godebug != "gotypesalias=0" {
if _, ok := A.Type().(*types.Alias); !ok {
t.Errorf("Expected A.Type() to be a types.Alias(). got %q", A.Type())
wantAlias := godebug == "gotypesalias=1"
_, gotAlias := A.Type().(*types.Alias)
if gotAlias != wantAlias {
verb := "to be"
if !wantAlias {
verb = "to not be"
}
t.Errorf("Expected A.Type() %s a types.Alias(). got %q", verb, A.Type())
}
})
}
@ -83,9 +87,12 @@ func TestNewAlias(t *testing.T) {
//
// Requires gotypesalias GODEBUG and aliastypeparams GOEXPERIMENT.
func TestNewParameterizedAlias(t *testing.T) {
testenv.NeedsGoExperiment(t, "aliastypeparams")
testenv.NeedsGo1Point(t, 23)
if testenv.Go1Point() == 23 {
testenv.NeedsGoExperiment(t, "aliastypeparams")
}
t.Setenv("GODEBUG", "gotypesalias=1") // needed until gotypesalias is removed (1.27).
t.Setenv("GODEBUG", "gotypesalias=1") // needed until gotypesalias is removed (1.27) or enabled by go.mod (1.23).
enabled := aliases.Enabled()
if !enabled {
t.Fatal("Need materialized aliases enabled")