// 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")
}
<-sync
}
}
- print("PASS\n")
}
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()
}
+++ /dev/null
-// $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)
-}
+++ /dev/null
-// $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)
-}
+++ /dev/null
-// $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
-}
+++ /dev/null
-// $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
-}
}
func (p *S) M() {
- print("M\n");
}
type I interface {
-// $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
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()
+}
-// $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
type T struct {a, b int};
+func println(x, y int) { }
+
func f(x interface{}) interface{} {
type T struct {a, b int};
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.
*/
== ./
-=========== ./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
== 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/
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
-// $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
}
func main() {
+ shouldPanic(p1)
+}
+
+func p1() {
var s *S
var i I
var e interface {}
_ = 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()
+}
-// $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
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()
+}
// $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"