MCPcopy Index your code
hub / github.com/go-errors/errors / TestStackFormat

Function TestStackFormat

error_test.go:56–86  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

54}
55
56func TestStackFormat(t *testing.T) {
57
58 defer func() {
59 err := recover()
60 if err != 'a' {
61 t.Fatal(err)
62 }
63
64 e, expected := Errorf("hi"), callers()
65
66 bs := [][]uintptr{e.stack, expected}
67
68 if err := compareStacks(bs[0], bs[1]); err != nil {
69 t.Errorf("Stack didn't match")
70 t.Errorf(err.Error())
71 }
72
73 stack := string(e.Stack())
74
75 if !strings.Contains(stack, "a: b(5)") {
76 t.Errorf("Stack trace does not contain source line: 'a: b(5)'")
77 t.Errorf(stack)
78 }
79 if !strings.Contains(stack, "error_test.go:") {
80 t.Errorf("Stack trace does not contain file name: 'error_test.go:'")
81 t.Errorf(stack)
82 }
83 }()
84
85 a()
86}
87
88func TestSkipWorks(t *testing.T) {
89

Callers

nothing calls this directly

Calls 6

ErrorfFunction · 0.85
callersFunction · 0.85
compareStacksFunction · 0.85
aFunction · 0.85
StackMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…