mirror of
https://github.com/golang/go
synced 2024-11-02 09:28:34 +00:00
test/nilptr: add more tests
These tests were suggested in golang.org/issue/6080. They were fixed as part of the new nil pointer checks that I added a few weeks ago. Recording the tests as part of marking the issue closed. Fixes #6080. R=golang-dev, r, bradfitz CC=golang-dev https://golang.org/cl/13255049
This commit is contained in:
parent
46f96079df
commit
1116f74e08
1 changed files with 28 additions and 0 deletions
|
@ -40,6 +40,10 @@ func main() {
|
|||
shouldPanic(p10)
|
||||
shouldPanic(p11)
|
||||
shouldPanic(p12)
|
||||
shouldPanic(p13)
|
||||
shouldPanic(p14)
|
||||
shouldPanic(p15)
|
||||
shouldPanic(p16)
|
||||
}
|
||||
|
||||
func shouldPanic(f func()) {
|
||||
|
@ -152,3 +156,27 @@ func p12() {
|
|||
var p *T = nil
|
||||
println(*(&((*p).i)))
|
||||
}
|
||||
|
||||
// Tests suggested in golang.org/issue/6080.
|
||||
|
||||
func p13() {
|
||||
var x *[10]int
|
||||
y := x[:]
|
||||
_ = y
|
||||
}
|
||||
|
||||
func p14() {
|
||||
println((*[1]int)(nil)[:])
|
||||
}
|
||||
|
||||
func p15() {
|
||||
for i := range (*[1]int)(nil)[:] {
|
||||
_ = i
|
||||
}
|
||||
}
|
||||
|
||||
func p16() {
|
||||
for i, v := range (*[1]int)(nil)[:] {
|
||||
_ = i + v
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue