From abe54b4badbc003dbbf7c287f51751f5286d3801 Mon Sep 17 00:00:00 2001 From: Dave Cheney Date: Mon, 23 May 2016 19:19:03 +1000 Subject: [PATCH] Added more Stack tests --- errors_test.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/errors_test.go b/errors_test.go index 53c3af1..7ffd7db 100644 --- a/errors_test.go +++ b/errors_test.go @@ -208,6 +208,21 @@ func TestStack(t *testing.T) { Cause(Wrap(New("ooh"), "ahh")), []fileline{ {"github.com/pkg/errors/errors_test.go", 208}, // this is the stack of New }, + }, { + func() error { return New("ooh") }(), []fileline{ + {"github.com/pkg/errors/errors_test.go", 212}, // this is the stack of New + {"github.com/pkg/errors/errors_test.go", 212}, // this is the stack of New's caller + }, + }, { + Cause(func() error { + return func() error { + return Errorf("hello %s", fmt.Sprintf("world")) + }() + }()), []fileline{ + {"github.com/pkg/errors/errors_test.go", 219}, // this is the stack of Errorf + {"github.com/pkg/errors/errors_test.go", 220}, // this is the stack of Errorf's caller + {"github.com/pkg/errors/errors_test.go", 221}, // this is the stack of Errorf's caller's caller + }, }} for _, tt := range tests { x, ok := tt.err.(interface {