Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / coc-go-data / tools / pkg / mod / golang.org / x / tools@v0.0.0-20201028153306-37f0764111ff / go / ssa / interp / testdata / recover.go
diff --git a/.config/coc/extensions/coc-go-data/tools/pkg/mod/golang.org/x/tools@v0.0.0-20201028153306-37f0764111ff/go/ssa/interp/testdata/recover.go b/.config/coc/extensions/coc-go-data/tools/pkg/mod/golang.org/x/tools@v0.0.0-20201028153306-37f0764111ff/go/ssa/interp/testdata/recover.go
new file mode 100644 (file)
index 0000000..b560052
--- /dev/null
@@ -0,0 +1,34 @@
+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))
+       }
+}