aboutsummaryrefslogtreecommitdiff
path: root/src/fmt/errors_test.go
diff options
context:
space:
mode:
authorMarcel van Lohuizen <mpvl@golang.org>2019-03-13 16:25:02 +0100
committerMarcel van Lohuizen <mpvl@golang.org>2019-03-14 09:45:22 +0000
commit1f90d081391d4f5911960fd28d81d7ea5e554a8f (patch)
tree56293e016a78493038bd21a68f783f33132d1583 /src/fmt/errors_test.go
parent8bf18b56a47a98b9dd2fa03beb358312237a8c76 (diff)
downloadgo-1f90d081391d4f5911960fd28d81d7ea5e554a8f.tar.xz
fmt: make type of fmt.Errorf the same as that of errors.New
This applies only for cases where %w is not used. The purpose of this change is to reduce test failures where tests depend on these two being the same type, as they previously were. Change-Id: I2dd28b93fe1d59f3cfbb4eb0875d1fb8ee699746 Reviewed-on: https://go-review.googlesource.com/c/go/+/167402 Run-TryBot: Marcel van Lohuizen <mpvl@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Damien Neil <dneil@google.com>
Diffstat (limited to 'src/fmt/errors_test.go')
-rw-r--r--src/fmt/errors_test.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/fmt/errors_test.go b/src/fmt/errors_test.go
index a3cd26ef3e..ed77709ea0 100644
--- a/src/fmt/errors_test.go
+++ b/src/fmt/errors_test.go
@@ -378,6 +378,21 @@ func TestErrorFormatter(t *testing.T) {
}
}
+func TestSameType(t *testing.T) {
+ err0 := errors.New("inner")
+ want := fmt.Sprintf("%T", err0)
+
+ err := fmt.Errorf("foo: %v", err0)
+ if got := fmt.Sprintf("%T", err); got != want {
+ t.Errorf("got %v; want %v", got, want)
+ }
+
+ err = fmt.Errorf("foo %s", "bar")
+ if got := fmt.Sprintf("%T", err); got != want {
+ t.Errorf("got %v; want %v", got, want)
+ }
+}
+
var _ errors.Formatter = wrapped{}
type wrapped struct {