go/loader: loosen a test assertion on go/types error messages

In CL 267717, the error message for invalid assignment of untyped values
is being corrected from 'cannot convert ...' to 'cannot use ... as ...
int ...'. This breaks the go/loader tests due to an assertion on the
former message.

Since the Go repo TryBots run x/tools tests, this assertion must be
loosened to allow merging the CL above.

Change-Id: I8a371397c9df58109090b7fd2eaa5b4a600776ef
Reviewed-on: https://go-review.googlesource.com/c/tools/+/267686
Run-TryBot: Robert Findley <rfindley@google.com>
Trust: Robert Findley <rfindley@google.com>
Trust: Robert Griesemer <gri@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
Rob Findley 2020-11-04 18:45:44 -05:00 committed by Robert Findley
parent 22bd85271a
commit bc3cf281b1
1 changed files with 6 additions and 3 deletions

View File

@ -645,8 +645,11 @@ func TestErrorReporting(t *testing.T) {
for pkg, info := range prog.AllPackages {
switch pkg.Path() {
case "a":
if !hasError(info.Errors, "cannot convert false") {
t.Errorf("a.Errors = %v, want bool conversion (type) error", info.Errors)
// The match below is unfortunately vague, because in go1.16 the error
// message in go/types changed from "cannot convert ..." to "cannot use
// ... as ... in assignment".
if !hasError(info.Errors, "cannot") {
t.Errorf("a.Errors = %v, want bool assignment (type) error", info.Errors)
}
if !hasError(info.Errors, "could not import c") {
t.Errorf("a.Errors = %v, want import (loader) error", info.Errors)
@ -659,7 +662,7 @@ func TestErrorReporting(t *testing.T) {
}
// Check errors reported via error handler.
if !hasError(allErrors, "cannot convert false") ||
if !hasError(allErrors, "cannot") ||
!hasError(allErrors, "rune literal not terminated") ||
!hasError(allErrors, "could not import c") {
t.Errorf("allErrors = %v, want syntax, type and loader errors", allErrors)