Skip to content

Commit

Permalink
go/types: add a test for argument error unwrapping
Browse files Browse the repository at this point in the history
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 <[email protected]>
Run-TryBot: Robert Findley <[email protected]>
TryBot-Result: Go Bot <[email protected]>
Reviewed-by: Robert Griesemer <[email protected]>
  • Loading branch information
findleyr committed Sep 22, 2021
1 parent 7158ae4 commit e925c46
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/go/types/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit e925c46

Please sign in to comment.