| 1 |
// Copyright 2017 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. |
| 4 |
|
| 5 |
package main |
| 6 |
|
| 7 |
import ( |
| 8 |
"log" |
| 9 |
"runtime" |
| 10 |
|
| 11 |
"./mysync" |
| 12 |
) |
| 13 |
|
| 14 |
func main() { |
| 15 |
var wg mysync.WaitGroup |
| 16 |
wg.Done() |
| 17 |
ci := runtime.CallersFrames(wg.Callers) |
| 18 |
frames := make([]runtime.Frame, 0, 4) |
| 19 |
for { |
| 20 |
frame, more := ci.Next() |
| 21 |
frames = append(frames, frame) |
| 22 |
if !more { |
| 23 |
break |
| 24 |
} |
| 25 |
} |
| 26 |
expecting := []string{ |
| 27 |
"test/mysync.(*WaitGroup).Add", |
| 28 |
"test/mysync.(*WaitGroup).Done", |
| 29 |
} |
| 30 |
for i := 0; i < 2; i++ { |
| 31 |
if frames[i].Function != expecting[i] { |
| 32 |
log.Fatalf("frame %d: got %s, want %s", i, frames[i].Function, expecting[i]) |
| 33 |
} |
| 34 |
} |
| 35 |
} |