aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/debug/heapdump_test.go
diff options
context:
space:
mode:
authorzhouguangyuan <zhouguangyuan.xian@gmail.com>2022-03-20 00:07:37 +0800
committerGopher Robot <gobot@golang.org>2022-04-12 00:32:29 +0000
commitec5e5dba6fbc4549f167c6db509a800e163296c8 (patch)
tree35fecc6163ac40b6e180de3cc26683df4a4afea7 /src/runtime/debug/heapdump_test.go
parentff14e844d26090e09aa335d836f737c09a7a0402 (diff)
downloadgo-ec5e5dba6fbc4549f167c6db509a800e163296c8.tar.xz
runtime: fix name of type parameter
CL 372774 is for reflect, this CL is for _type in runtime. Add a test case to ensure the name method of _type can be exercised. Updates #50208 Change-Id: I26ccf8c5c574dd9e78510cf29eb40ae7c8d449ab Reviewed-on: https://go-review.googlesource.com/c/go/+/393917 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> Run-TryBot: Keith Randall <khr@google.com> Auto-Submit: Keith Randall <khr@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
Diffstat (limited to 'src/runtime/debug/heapdump_test.go')
-rw-r--r--src/runtime/debug/heapdump_test.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/runtime/debug/heapdump_test.go b/src/runtime/debug/heapdump_test.go
index 768934d05d..ee6b054b11 100644
--- a/src/runtime/debug/heapdump_test.go
+++ b/src/runtime/debug/heapdump_test.go
@@ -67,3 +67,29 @@ func TestWriteHeapDumpFinalizers(t *testing.T) {
WriteHeapDump(f.Fd())
println("done dump")
}
+
+type G[T any] struct{}
+type I interface {
+ M()
+}
+
+//go:noinline
+func (g G[T]) M() {}
+
+var dummy I = G[int]{}
+var dummy2 I = G[G[int]]{}
+
+func TestWriteHeapDumpTypeName(t *testing.T) {
+ if runtime.GOOS == "js" {
+ t.Skipf("WriteHeapDump is not available on %s.", runtime.GOOS)
+ }
+ f, err := os.CreateTemp("", "heapdumptest")
+ if err != nil {
+ t.Fatalf("TempFile failed: %v", err)
+ }
+ defer os.Remove(f.Name())
+ defer f.Close()
+ WriteHeapDump(f.Fd())
+ dummy.M()
+ dummy2.M()
+}