blob: b5600522633a8b5fe4ee0720a7e4b2d47329b6ca [file] [log] [blame]
package main
// Tests of panic/recover.
import "fmt"
func fortyTwo() (r int) {
r = 42
// The next two statements simulate a 'return' statement.
defer func() { recover() }()
panic(nil)
}
func zero() int {
defer func() { recover() }()
panic(1)
}
func zeroEmpty() (int, string) {
defer func() { recover() }()
panic(1)
}
func main() {
if r := fortyTwo(); r != 42 {
panic(r)
}
if r := zero(); r != 0 {
panic(r)
}
if r, s := zeroEmpty(); r != 0 || s != "" {
panic(fmt.Sprint(r, s))
}
}