| // Copyright 2017 The Go Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style |
| // license that can be found in the LICENSE file. |
| x.pc, x.file, x.line, x.ok = runtime.Caller(skip) // line 36 |
| func testCaller(skp int) frame { |
| panic(fmt.Sprintf("skip=%d runtime.Caller failed", skp)) |
| var expected = []wantFrame{ |
| 3: {"main.testCaller", 42}, |
| 6: {"runtime.goexit", -1}, |
| for i := 0; i <= 6; i++ { |
| frame := testCaller(i) // line 68 |
| fn := runtime.FuncForPC(frame.pc) |
| if expected[i].line >= 0 && frame.line != expected[i].line { |
| panic(fmt.Sprintf("skip=%d expected line %d, got line %d", i, expected[i].line, frame.line)) |
| if fn.Name() != expected[i].funcName { |
| panic(fmt.Sprintf("skip=%d expected function %s, got %s", i, expected[i].funcName, fn.Name())) |