mirror of
https://github.com/golang/go
synced 2024-09-30 02:24:43 -06:00
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 <gri@google.com> Reviewed-by: Robert Findley <rfindley@google.com> Reviewed-by: Robert Griesemer <gri@google.com> Run-TryBot: Robert Griesemer <gri@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
parent
2dbc5736b2
commit
140bc24445
@ -9,8 +9,10 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TestErrorCalls makes sure that check.errorf calls have at
|
const errorfMinArgCount = 4
|
||||||
// least 3 arguments (otherwise we should be using check.error).
|
|
||||||
|
// TestErrorCalls makes sure that check.errorf calls have at least
|
||||||
|
// errorfMinArgCount arguments (otherwise we should use check.error).
|
||||||
func TestErrorCalls(t *testing.T) {
|
func TestErrorCalls(t *testing.T) {
|
||||||
files, err := pkgFiles(".")
|
files, err := pkgFiles(".")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -30,11 +32,11 @@ func TestErrorCalls(t *testing.T) {
|
|||||||
if !(isName(selx.X, "check") && isName(selx.Sel, "errorf")) {
|
if !(isName(selx.X, "check") && isName(selx.Sel, "errorf")) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
// check.errorf calls should have more than 2 arguments:
|
// check.errorf calls should have at least errorfMinArgCount arguments:
|
||||||
// position, format string, and arguments to format
|
// position, code, format string, and arguments to format
|
||||||
if n := len(call.ArgList); n <= 2 {
|
if n := len(call.ArgList); n < errorfMinArgCount {
|
||||||
t.Errorf("%s: got %d arguments, want > 2", call.Pos(), n)
|
t.Errorf("%s: got %d arguments, want at least %d", call.Pos(), n, errorfMinArgCount)
|
||||||
return true
|
return false
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user