1 // Copyright 2011 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
14 func (t *T) ptrmethod() []byte {
17 func (t T) method() []byte {
22 The traceback should look something like this, modulo line numbers and hex constants.
23 Don't worry much about the base levels, but check the ones in our own package.
25 /Users/r/go/src/pkg/runtime/debug/stack_test.go:15 (0x13878)
26 *T.ptrmethod: return Stack()
27 /Users/r/go/src/pkg/runtime/debug/stack_test.go:18 (0x138dd)
28 T.method: return t.ptrmethod()
29 /Users/r/go/src/pkg/runtime/debug/stack_test.go:23 (0x13920)
30 TestStack: b := T(0).method()
31 /Users/r/go/src/pkg/testing/testing.go:132 (0x14a7a)
33 /Users/r/go/src/pkg/runtime/proc.c:145 (0xc970)
34 ???: runtimeĀ·unlock(&runtimeĀ·sched);
36 func TestStack(t *testing.T) {
38 lines := strings.Split(string(b), "\n", -1)
40 t.Fatal("too few lines")
42 check(t, lines[0], "src/pkg/runtime/debug/stack_test.go")
43 check(t, lines[1], "\t*T.ptrmethod: return Stack()")
44 check(t, lines[2], "src/pkg/runtime/debug/stack_test.go")
45 check(t, lines[3], "\tT.method: return t.ptrmethod()")
46 check(t, lines[4], "src/pkg/runtime/debug/stack_test.go")
47 check(t, lines[5], "\tTestStack: b := T(0).method()")
48 check(t, lines[6], "src/pkg/testing/testing.go")
51 func check(t *testing.T, line, has string) {
52 if strings.Index(line, has) < 0 {
53 t.Errorf("expected %q in %q", has, line)