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
16 var x = make([]byte, 10)
28 func mustRecover(s string) {
31 panic("expected panic")
33 if e := v.(error).Error(); strings.Index(e, s) < 0 {
34 panic("want: " + s + "; have: " + e)
39 defer mustRecover("index")
44 defer mustRecover("slice")
49 defer mustRecover("slice")
56 defer mustRecover("interface")
67 defer mustRecover("uncomparable")
74 defer mustRecover("unhashable type main.T")
77 m := make(map[interface{}]int)
82 defer mustRecover("divide by zero")