From: Robert Griesemer Date: Mon, 10 Oct 2022 20:22:16 +0000 (-0700) Subject: cmd/compile/internal/types2: adjust errorcalls_test and apply it X-Git-Tag: go1.20rc1~673 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=140bc24445f3c86b61bfb4d924e1e26f477574a2;p=gostls13.git cmd/compile/internal/types2: adjust errorcalls_test and apply it Checker.errorf calls now have an error code and thus require at least 4 arguments. Change-Id: Id01c30d5d3cc747ab0b3ba4001e88985192f2d80 Reviewed-on: https://go-review.googlesource.com/c/go/+/441957 Auto-Submit: Robert Griesemer Reviewed-by: Robert Findley Reviewed-by: Robert Griesemer Run-TryBot: Robert Griesemer TryBot-Result: Gopher Robot --- diff --git a/src/cmd/compile/internal/types2/errorcalls_test.go b/src/cmd/compile/internal/types2/errorcalls_test.go index 80b05f9f0f..edf2a5195d 100644 --- a/src/cmd/compile/internal/types2/errorcalls_test.go +++ b/src/cmd/compile/internal/types2/errorcalls_test.go @@ -9,8 +9,10 @@ import ( "testing" ) -// TestErrorCalls makes sure that check.errorf calls have at -// least 3 arguments (otherwise we should be using check.error). +const errorfMinArgCount = 4 + +// TestErrorCalls makes sure that check.errorf calls have at least +// errorfMinArgCount arguments (otherwise we should use check.error). func TestErrorCalls(t *testing.T) { files, err := pkgFiles(".") if err != nil { @@ -30,11 +32,11 @@ func TestErrorCalls(t *testing.T) { if !(isName(selx.X, "check") && isName(selx.Sel, "errorf")) { return false } - // check.errorf calls should have more than 2 arguments: - // position, format string, and arguments to format - if n := len(call.ArgList); n <= 2 { - t.Errorf("%s: got %d arguments, want > 2", call.Pos(), n) - return true + // check.errorf calls should have at least errorfMinArgCount arguments: + // position, code, format string, and arguments to format + if n := len(call.ArgList); n < errorfMinArgCount { + t.Errorf("%s: got %d arguments, want at least %d", call.Pos(), n, errorfMinArgCount) + return false } return false })