mirror of
https://github.com/golang/go
synced 2024-11-02 13:21:55 +00:00
test: add test for export/import of recover & defer
Add a simple test with an exported generic function that does recover/defer, to test that recover/defer are exported/imported properly (and a generic function with recover/defer works fine). Change-Id: Idc3af101cbb78fc96bf945f1f5eab2740dd8994b Reviewed-on: https://go-review.googlesource.com/c/go/+/353883 Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Trust: Dan Scales <danscales@google.com>
This commit is contained in:
parent
0d6561b72b
commit
695a59b513
4 changed files with 37 additions and 0 deletions
16
test/typeparam/recoverimp.dir/a.go
Normal file
16
test/typeparam/recoverimp.dir/a.go
Normal file
|
@ -0,0 +1,16 @@
|
|||
// Copyright 2021 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.
|
||||
|
||||
package a
|
||||
|
||||
import "fmt"
|
||||
|
||||
func F[T any](a T) {
|
||||
defer func() {
|
||||
if x := recover(); x != nil {
|
||||
fmt.Printf("panic: %v\n", x)
|
||||
}
|
||||
}()
|
||||
panic(a)
|
||||
}
|
12
test/typeparam/recoverimp.dir/main.go
Normal file
12
test/typeparam/recoverimp.dir/main.go
Normal file
|
@ -0,0 +1,12 @@
|
|||
// Copyright 2021 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.
|
||||
|
||||
package main
|
||||
|
||||
import "a"
|
||||
|
||||
func main() {
|
||||
a.F(5.3)
|
||||
a.F("hello")
|
||||
}
|
7
test/typeparam/recoverimp.go
Normal file
7
test/typeparam/recoverimp.go
Normal file
|
@ -0,0 +1,7 @@
|
|||
// rundir -G=3
|
||||
|
||||
// Copyright 2021 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.
|
||||
|
||||
package ignored
|
2
test/typeparam/recoverimp.out
Normal file
2
test/typeparam/recoverimp.out
Normal file
|
@ -0,0 +1,2 @@
|
|||
panic: 5.3
|
||||
panic: hello
|
Loading…
Reference in a new issue