]> Cypherpunks.ru repositories - gostls13.git/blobdiff - test/recover2.go
cmd/compile/internal/inline: score call sites exposed by inlines
[gostls13.git] / test / recover2.go
index c95af8f62f836825e399e7459a6b230a6a1d6bbd..31c06ba2dc1449a0dd51bef2b446461fcba93d67 100644 (file)
@@ -1,22 +1,17 @@
-// $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 of recover for run-time errors.
 
 // TODO(rsc):
-//     integer divide by zero?
 //     null pointer accesses
 
 package main
 
-import (
-       "os"
-       "strings"
-       "syscall"
-)
+import "strings"
 
 var x = make([]byte, 10)
 
@@ -35,7 +30,7 @@ func mustRecover(s string) {
        if v == nil {
                panic("expected panic")
        }
-       if e := v.(os.Error).String(); strings.Index(e, s) < 0 {
+       if e := v.(error).Error(); strings.Index(e, s) < 0 {
                panic("want: " + s + "; have: " + e)
        }
 }
@@ -60,11 +55,12 @@ func test3() {
 func test4() {
        defer mustRecover("interface")
        var x interface{} = 1
-       println(x.(float))
+       println(x.(float32))
 }
 
 type T struct {
        a, b int
+       c    []int
 }
 
 func test5() {
@@ -75,7 +71,7 @@ func test5() {
 }
 
 func test6() {
-       defer mustRecover("unhashable")
+       defer mustRecover("unhashable type main.T")
        var x T
        var z interface{} = x
        m := make(map[interface{}]int)
@@ -83,10 +79,6 @@ func test6() {
 }
 
 func test7() {
-       if syscall.ARCH == "arm" || syscall.OS == "nacl" {
-               // ARM doesn't have integer divide trap yet
-               return
-       }
        defer mustRecover("divide by zero")
        var x, y int
        println(x / y)