1 // $G $D/$F.go && $L $F.$A && ./$A.out
3 // Copyright 2010 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
7 // Test of recover for run-time errors.
10 // null pointer accesses
19 var x = make([]byte, 10)
31 func mustRecover(s string) {
34 panic("expected panic")
36 if e := v.(os.Error).String(); strings.Index(e, s) < 0 {
37 panic("want: " + s + "; have: " + e)
42 defer mustRecover("index")
47 defer mustRecover("slice")
52 defer mustRecover("slice")
59 defer mustRecover("interface")
69 defer mustRecover("uncomparable")
76 defer mustRecover("unhashable")
79 m := make(map[interface{}]int)
84 defer mustRecover("divide by zero")