| // $G $D/$F.go && $L $F.$A && ./$A.out |
| // 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 of recover for run-time errors. |
| // integer divide by zero? |
| func mustRecover(s string) { |
| if e := v.(os.Error).String(); strings.Index(e, s) < 0 { |
| panic("want: " + s + "; have: " + e) |
| defer mustRecover("index") |
| defer mustRecover("slice") |
| defer mustRecover("slice") |
| defer mustRecover("interface") |
| defer mustRecover("uncomparable") |
| defer mustRecover("unhashable") |
| m := make(map[interface{}]int) |
| if syscall.ARCH == "arm" || syscall.OS == "nacl" { |
| // ARM doesn't have integer divide trap yet |
| defer mustRecover("divide by zero") |