Skip to content

Commit 9240976

Browse files
committed
Add additional test for Trace().
1 parent 40bdcc6 commit 9240976

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

stackinternal_test.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,34 @@ func TestCaller(t *testing.T) {
3131
t.Errorf("got line == %v, want line == %v", got, want)
3232
}
3333
}
34+
35+
type fholder struct {
36+
f func() CallStack
37+
}
38+
39+
func (fh *fholder) labyrinth() CallStack {
40+
for {
41+
return fh.f()
42+
}
43+
}
44+
45+
func TestTrace(t *testing.T) {
46+
t.Parallel()
47+
48+
fh := fholder{
49+
f: func() CallStack {
50+
cs := Trace()
51+
return cs
52+
},
53+
}
54+
55+
cs := fh.labyrinth()
56+
57+
lines := []int{50, 41, 55}
58+
59+
for i, line := range lines {
60+
if got, want := cs[i].line(), line; got != want {
61+
t.Errorf("got line[%d] == %v, want line[%d] == %v", i, got, i, want)
62+
}
63+
}
64+
}

0 commit comments

Comments
 (0)