1
0
mirror of https://github.com/golang/go synced 2024-11-26 21:51:44 -07:00

cmd/go/internal/load: improve comments

This change modifies test.go
isTestFunc checked whether the parameter type is B, M or T before the version of Go1.17.
But, after Go1.18, isTestFunc checks F, too.
This commit is contained in:
sivchari 2022-10-10 23:47:45 +09:00
parent 20ea988421
commit 507d5b1f74

View File

@ -560,7 +560,7 @@ func recompileForTest(pmain, preal, ptest, pxtest *Package) *PackageError {
} }
// isTestFunc tells whether fn has the type of a testing function. arg // isTestFunc tells whether fn has the type of a testing function. arg
// specifies the parameter type we look for: B, M or T. // specifies the parameter type we look for: B, F, M or T.
func isTestFunc(fn *ast.FuncDecl, arg string) bool { func isTestFunc(fn *ast.FuncDecl, arg string) bool {
if fn.Type.Results != nil && len(fn.Type.Results.List) > 0 || if fn.Type.Results != nil && len(fn.Type.Results.List) > 0 ||
fn.Type.Params.List == nil || fn.Type.Params.List == nil ||
@ -575,7 +575,7 @@ func isTestFunc(fn *ast.FuncDecl, arg string) bool {
// We can't easily check that the type is *testing.M // We can't easily check that the type is *testing.M
// because we don't know how testing has been imported, // because we don't know how testing has been imported,
// but at least check that it's *M or *something.M. // but at least check that it's *M or *something.M.
// Same applies for B and T. // Same applies for B, F and T.
if name, ok := ptr.X.(*ast.Ident); ok && name.Name == arg { if name, ok := ptr.X.(*ast.Ident); ok && name.Name == arg {
return true return true
} }