1
0
mirror of https://github.com/golang/go synced 2024-11-17 03:14:50 -07:00

go/types: add a test for argument error unwrapping

Add a sanity-check test that ArgumentErrors unwrap their inner Err.

Change-Id: I5a670a490deeabc03a64e42b3843f79d622ba958
Reviewed-on: https://go-review.googlesource.com/c/go/+/351338
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
Robert Findley 2021-09-21 20:58:33 -04:00
parent 7158ae4e32
commit e925c4640d

View File

@ -2012,6 +2012,20 @@ func TestInstantiateErrors(t *testing.T) {
}
}
func TestArgumentErrorUnwrapping(t *testing.T) {
var err error = &ArgumentError{
Index: 1,
Err: Error{Msg: "test"},
}
var e Error
if !errors.As(err, &e) {
t.Fatalf("error %v does not wrap types.Error", err)
}
if e.Msg != "test" {
t.Errorf("e.Msg = %q, want %q", e.Msg, "test")
}
}
func TestInstanceIdentity(t *testing.T) {
imports := make(testImporter)
conf := Config{Importer: imports}