Commit 4bdf1fc0 authored by Russ Cox's avatar Russ Cox

test: silence/coalesce some tests

Add copyright notice to nilptr.go.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5139048
parent 4c462e6f
...@@ -82,5 +82,4 @@ func main() { ...@@ -82,5 +82,4 @@ func main() {
// However, the result of the bug linked to at the top is that we'll // 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". // end up panicking with: "throw: bad g->status in ready".
recver(cmux) recver(cmux)
print("PASS\n")
} }
...@@ -279,5 +279,4 @@ func main() { ...@@ -279,5 +279,4 @@ func main() {
<-sync <-sync
} }
} }
print("PASS\n")
} }
...@@ -127,4 +127,44 @@ func main() { ...@@ -127,4 +127,44 @@ func main() {
istrue(z == x) istrue(z == x)
isfalse(z == y) 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()
} }
// $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)
}
// $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)
}
// $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
}
// $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
}
...@@ -10,7 +10,6 @@ type S struct { ...@@ -10,7 +10,6 @@ type S struct {
} }
func (p *S) M() { func (p *S) M() {
print("M\n");
} }
type I interface { 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. // Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
...@@ -21,8 +21,24 @@ func main() { ...@@ -21,8 +21,24 @@ func main() {
if foo2(v2) != 1 { if foo2(v2) != 1 {
panic(2) panic(2)
} }
shouldPanic(p1)
}
func p1() {
var i I
i = 1
var v3 = i.(int32) // This type conversion should fail at runtime. var v3 = i.(int32) // This type conversion should fail at runtime.
if foo2(v3) != 1 { if foo2(v3) != 1 {
panic(3) 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. // Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
...@@ -8,6 +8,8 @@ package main ...@@ -8,6 +8,8 @@ package main
type T struct {a, b int}; type T struct {a, b int};
func println(x, y int) { }
func f(x interface{}) interface{} { func f(x interface{}) interface{} {
type T struct {a, b int}; type T struct {a, b int};
...@@ -24,16 +26,29 @@ func main() { ...@@ -24,16 +26,29 @@ func main() {
inner_T := f(nil); inner_T := f(nil);
f(inner_T); f(inner_T);
shouldPanic(p1)
}
func p1() {
outer_T := T{5, 7}; outer_T := T{5, 7};
f(outer_T); f(outer_T);
} }
func shouldPanic(f func()) {
defer func() {
if recover() == nil {
panic("function should panic")
}
}()
f()
}
/* /*
This prints: This prints:
2 3 2 3
5 7 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. 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 =========== ./deferprint.go
printing: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 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 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 ...@@ -97,20 +85,8 @@ abcxyz-abcxyz-abcxyz-abcxyz-abcxyz-abcxyz-abcxyz
== chan/ == chan/
=========== chan/doubleselect.go
PASS
=========== chan/nonblock.go
PASS
== interface/ == 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/ == syntax/
== dwarf/ == dwarf/
...@@ -139,16 +115,6 @@ inner loop top i 0 ...@@ -139,16 +115,6 @@ inner loop top i 0
do break do break
broke 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 =========== fixedbugs/bug328.go
0x0 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. // Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
...@@ -13,6 +13,10 @@ type I interface { ...@@ -13,6 +13,10 @@ type I interface {
} }
func main() { func main() {
shouldPanic(p1)
}
func p1() {
var s *S var s *S
var i I var i I
var e interface {} var e interface {}
...@@ -21,6 +25,14 @@ func main() { ...@@ -21,6 +25,14 @@ func main() {
_ = i _ = i
} }
// hide S down here to avoid static warning
type S struct { 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. // Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
...@@ -18,8 +18,21 @@ type I1 interface { Name() int8 } ...@@ -18,8 +18,21 @@ type I1 interface { Name() int8 }
type I2 interface { Name() int64 } type I2 interface { Name() int64 }
func main() { func main() {
shouldPanic(p1)
}
func p1() {
var i1 I1 var i1 I1
var s *S var s *S
i1 = s i1 = s
print(i1.(I2).Name()) 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 // $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 package main
import "unsafe" import "unsafe"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment