]> Cypherpunks repositories - gostls13.git/commitdiff
test: silence/coalesce some tests
authorRuss Cox <rsc@golang.org>
Mon, 26 Sep 2011 23:35:21 +0000 (19:35 -0400)
committerRuss Cox <rsc@golang.org>
Mon, 26 Sep 2011 23:35:21 +0000 (19:35 -0400)
Add copyright notice to nilptr.go.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5139048

14 files changed:
test/chan/doubleselect.go
test/chan/nonblock.go
test/cmp.go [moved from test/cmp1.go with 82% similarity]
test/cmp2.go [deleted file]
test/cmp3.go [deleted file]
test/cmp4.go [deleted file]
test/cmp5.go [deleted file]
test/fixedbugs/bug093.go
test/fixedbugs/bug113.go
test/fixedbugs/bug148.go
test/golden.out
test/interface/fail.go
test/interface/returntype.go
test/nilptr.go

index 3c7412ed6ab56f071f1428c02b397cf2e3039081..f8d50c90c0f5c7dc60f275622c527e1855286015 100644 (file)
@@ -82,5 +82,4 @@ func main() {
        // However, the result of the bug linked to at the top is that we'll
        // end up panicking with: "throw: bad g->status in ready".
        recver(cmux)
-       print("PASS\n")
 }
index 33afb3291652b11f93da64001ba36d85a84c5cb9..9addf12e99ac7af30fd8b15b7e1d5eba472cdc4a 100644 (file)
@@ -279,5 +279,4 @@ func main() {
                        <-sync
                }
        }
-       print("PASS\n")
 }
similarity index 82%
rename from test/cmp1.go
rename to test/cmp.go
index 698544c58219413651c0533fc7a36e457b45c1a3..570487db6af707f7d5a0f92e162fe5831651542b 100644 (file)
@@ -127,4 +127,44 @@ func main() {
                istrue(z == x)
                isfalse(z == y)
        }
+       
+       shouldPanic(p1)
+       shouldPanic(p2)
+       shouldPanic(p3)
+       shouldPanic(p4)
+}
+
+func p1() {
+       var a []int
+       var ia interface{} = a
+       use(ia == ia)
+}
+
+func p2() {
+       var b []int
+       var ib interface{} = b
+       use(ib == ib)
+}
+
+func p3() {
+       var a []int
+       var ia interface{} = a
+       var m = make(map[interface{}] int)
+       m[ia] = 1
+}
+
+func p4() {
+       var b []int
+       var ib interface{} = b
+       var m = make(map[interface{}] int)
+       m[ib] = 1
+}
+
+func shouldPanic(f func()) {
+       defer func() {
+               if recover() == nil {
+                       panic("function should panic")
+               }
+       }()
+       f()
 }
diff --git a/test/cmp2.go b/test/cmp2.go
deleted file mode 100644 (file)
index f6f124f..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-// $G $D/$F.go && $L $F.$A && ! ./$A.out
-
-// Copyright 2009 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.
-
-package main
-
-func use(bool) { }
-
-func main() {
-       var a []int
-       var ia interface{} = a
-       use(ia == ia)
-}
diff --git a/test/cmp3.go b/test/cmp3.go
deleted file mode 100644 (file)
index dd90bfb..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-// $G $D/$F.go && $L $F.$A && ! ./$A.out
-
-// Copyright 2009 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.
-
-package main
-
-func use(bool) { }
-
-func main() {
-       var b []int
-       var ib interface{} = b
-       use(ib == ib)
-}
diff --git a/test/cmp4.go b/test/cmp4.go
deleted file mode 100644 (file)
index 3f9b2c0..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-// $G $D/$F.go && $L $F.$A && ! ./$A.out
-
-// Copyright 2009 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.
-
-package main
-
-func main() {
-       var a []int
-       var ia interface{} = a
-       var m = make(map[interface{}] int)
-       m[ia] = 1
-}
diff --git a/test/cmp5.go b/test/cmp5.go
deleted file mode 100644 (file)
index 3a7d733..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-// $G $D/$F.go && $L $F.$A && ! ./$A.out
-
-// Copyright 2009 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.
-
-package main
-
-func main() {
-       var b []int
-       var ib interface{} = b
-       var m = make(map[interface{}] int)
-       m[ib] = 1
-}
index f80eee01fa7fb09815273a44f0a94ab51a1341c7..52d92c7e3d4c668414ac3cf97a742ae5e8c6461a 100644 (file)
@@ -10,7 +10,6 @@ type S struct {
 }
 
 func (p *S) M() {
-       print("M\n");
 }
 
 type I interface {
index 4fd322d53111e9839d9a354ae8bc27556915dd47..4ca07dc65a72da31cbf1c206658834f1de489d70 100644 (file)
@@ -1,4 +1,4 @@
-// $G $D/$F.go && $L $F.$A && (! ./$A.out || echo BUG: should not succeed)
+// $G $D/$F.go && $L $F.$A && ./$A.out
 
 // Copyright 2009 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
@@ -21,8 +21,24 @@ func main() {
        if foo2(v2) != 1 {
                panic(2)
        }
+       
+       shouldPanic(p1)
+}
+
+func p1() {
+       var i I
+       i = 1
        var v3 = i.(int32) // This type conversion should fail at runtime.
        if foo2(v3) != 1 {
                panic(3)
        }
 }
+
+func shouldPanic(f func()) {
+       defer func() {
+               if recover() == nil {
+                       panic("function should panic")
+               }
+       }()
+       f()
+}
index daedff10537198b7809b1f0ea473c494894b65e9..251020c96f79e94a505c6cf35a855fd098b506e7 100644 (file)
@@ -1,4 +1,4 @@
-// $G $D/$F.go && $L $F.$A && ! ./$A.out || echo BUG: should crash
+// $G $D/$F.go && $L $F.$A && ./$A.out
 
 // Copyright 2009 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
@@ -8,6 +8,8 @@ package main
 
 type T struct {a, b int};
 
+func println(x, y int) { }
+
 func f(x interface{}) interface{} {
        type T struct {a, b int};
 
@@ -24,16 +26,29 @@ func main() {
        inner_T := f(nil);
        f(inner_T);
 
+       shouldPanic(p1)
+}
+
+func p1() {
        outer_T := T{5, 7};
        f(outer_T);
 }
 
+func shouldPanic(f func()) {
+       defer func() {
+               if recover() == nil {
+                       panic("function should panic")
+               }
+       }()
+       f()
+}
+
 /*
 This prints:
 
 2 3
 5 7
 
-but it should crash: The type assertion on line 14 should fail
+but it should crash: The type assertion on line 18 should fail
 for the 2nd call to f with outer_T.
 */
index 27c932f65c9076120498811f698711f1c36d1167..f2e7f5ce3043eda283d02c9c6cd3d598b06e5241 100644 (file)
@@ -1,18 +1,6 @@
 
 == ./
 
-=========== ./cmp2.go
-panic: runtime error: comparing uncomparable type []int
-
-=========== ./cmp3.go
-panic: runtime error: comparing uncomparable type []int
-
-=========== ./cmp4.go
-panic: runtime error: hash of unhashable type []int
-
-=========== ./cmp5.go
-panic: runtime error: hash of unhashable type []int
-
 =========== ./deferprint.go
 printing: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
 42 true false true +1.500000e+000 world 0x0 [0/0]0x0 0x0 0x0 255
@@ -97,20 +85,8 @@ abcxyz-abcxyz-abcxyz-abcxyz-abcxyz-abcxyz-abcxyz
 
 == chan/
 
-=========== chan/doubleselect.go
-PASS
-
-=========== chan/nonblock.go
-PASS
-
 == interface/
 
-=========== interface/fail.go
-panic: interface conversion: *main.S is not main.I: missing method Foo
-
-=========== interface/returntype.go
-panic: interface conversion: *main.S is not main.I2: missing method Name
-
 == syntax/
 
 == dwarf/
@@ -139,16 +115,6 @@ inner loop top i 0
 do break
 broke
 
-=========== fixedbugs/bug093.go
-M
-
-=========== fixedbugs/bug113.go
-panic: interface conversion: interface is int, not int32
-
-=========== fixedbugs/bug148.go
-2 3
-panic: interface conversion: interface is main.T, not main.T
-
 =========== fixedbugs/bug328.go
 0x0
 
index 3e741d3f91ab93f63bb7c7075c352c0df85ed99c..0c20bcf756a4275b505eb5ab07edf5ba961f9d63 100644 (file)
@@ -1,4 +1,4 @@
-// $G $D/$F.go && $L $F.$A && ./$A.out
+// $G $D/$F.go && $L $F.$A && ./$A.out
 
 // Copyright 2009 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
@@ -13,6 +13,10 @@ type I interface {
 }
 
 func main() {
+       shouldPanic(p1)
+}
+
+func p1() {
        var s *S
        var i I
        var e interface {}
@@ -21,6 +25,14 @@ func main() {
        _ = i
 }
 
-// hide S down here to avoid static warning
 type S struct {
 }
+
+func shouldPanic(f func()) {
+       defer func() {
+               if recover() == nil {
+                       panic("function should panic")
+               }
+       }()
+       f()
+}
index c526b3b0ece0d5679ca931396fb2e5c5cc90dc93..5cf083617813495b1da44ac203044620d2551742 100644 (file)
@@ -1,4 +1,4 @@
-// $G $D/$F.go && $L $F.$A && (! ./$A.out || echo BUG: should not succeed)
+// $G $D/$F.go && $L $F.$A && ./$A.out
 
 // Copyright 2009 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
@@ -18,8 +18,21 @@ type I1 interface { Name() int8 }
 type I2 interface { Name() int64 }
 
 func main() {
+       shouldPanic(p1)
+}
+
+func p1() {
        var i1 I1
        var s *S
        i1 = s
        print(i1.(I2).Name())
 }
+
+func shouldPanic(f func()) {
+       defer func() {
+               if recover() == nil {
+                       panic("function should panic")
+               }
+       }()
+       f()
+}
index 41d8f23528149eac9aefb5d2efcb387fdc97c5e7..6cf21920473c3dc6b10d43628882cc41f53ef3f2 100644 (file)
@@ -1,5 +1,9 @@
 // $G $D/$F.go && $L $F.$A && ./$A.out
 
+// Copyright 2011 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.
+
 package main
 
 import "unsafe"