]> Cypherpunks.ru repositories - gostls13.git/blobdiff - test/recover3.go
cmd/compile/internal/inline: score call sites exposed by inlines
[gostls13.git] / test / recover3.go
index 2aa1df616dcae347f8cb64fef3eb7a3f9a064e9e..1b26cb36367dcdd206b8b30dd5aad3e371fb9137 100644 (file)
@@ -1,9 +1,11 @@
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// run
 
-// Copyright 2010 The Go Authors.  All rights reserved.
+// Copyright 2010 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.
 
+// Test recovering from runtime errors.
+
 package main
 
 import (
@@ -35,7 +37,7 @@ func check(name string, f func(), err string) {
                        println(name, "panicked but not with runtime.Error")
                        return
                }
-               s := runt.String()
+               s := runt.Error()
                if strings.Index(s, err) < 0 {
                        bug()
                        println(name, "panicked with", s, "not", err)
@@ -62,13 +64,18 @@ func main() {
 
        i = 99999
        var sl []int
-       check("array-bounds", func() { println(p[i]) }, "index out of range")
+       p1 := new([10]int)
+       check("array-bounds", func() { println(p1[i]) }, "index out of range")
        check("slice-bounds", func() { println(sl[i]) }, "index out of range")
 
        var inter interface{}
        inter = 1
        check("type-concrete", func() { println(inter.(string)) }, "int, not string")
        check("type-interface", func() { println(inter.(m)) }, "missing method m")
+
+       if didbug {
+               panic("recover3")
+       }
 }
 
 type m interface {