summaryrefslogtreecommitdiff
path: root/test/fixedbugs/bug242.go
diff options
context:
space:
mode:
Diffstat (limited to 'test/fixedbugs/bug242.go')
-rw-r--r--test/fixedbugs/bug242.go52
1 files changed, 31 insertions, 21 deletions
diff --git a/test/fixedbugs/bug242.go b/test/fixedbugs/bug242.go
index 833e0a7dc..5c21eaaf0 100644
--- a/test/fixedbugs/bug242.go
+++ b/test/fixedbugs/bug242.go
@@ -10,6 +10,7 @@ package main
var i byte = 0
var a [30]byte
+
func f() *byte {
i++
return &a[i-1]
@@ -28,35 +29,39 @@ func x() (byte, byte) {
}
func e1(c chan byte, expected byte) chan byte {
if i != expected {
- panicln("e1: got", i, "expected", expected)
+ println("e1: got", i, "expected", expected)
+ panic("fail")
}
i++
return c
}
-type Empty interface {}
+type Empty interface{}
type I interface {
Get() byte
}
type S1 struct {
i byte
}
-func (p S1) Get() byte {
- return p.i
-}
+
+func (p S1) Get() byte { return p.i }
+
type S2 struct {
i byte
}
+
func e2(p Empty, expected byte) Empty {
if i != expected {
- panicln("e2: got", i, "expected", expected)
+ println("e2: got", i, "expected", expected)
+ panic("fail")
}
i++
return p
}
func e3(p *I, expected byte) *I {
if i != expected {
- panicln("e3: got", i, "expected", expected)
+ println("e3: got", i, "expected", expected)
+ panic("fail")
}
i++
return p
@@ -67,55 +72,60 @@ func main() {
a[i] = ' '
}
- // 0 1 2 3 4 5
+ // 0 1 2 3 4 5
*f(), *f(), *f() = gbyte(), gbyte(), gbyte()
- // 6 7 8
+ // 6 7 8
*f(), *f() = x()
m := make(map[byte]byte)
m[10] = 'A'
var p1, p2 bool
- // 9 10
+ // 9 10
*f(), p1 = m[gint()]
- // 11 12
+ // 11 12
*f(), p2 = m[gint()]
a[11] += '0'
if !p1 || p2 {
- panicln("bad map check", i, p1, p2)
+ println("bad map check", i, p1, p2)
+ panic("fail")
}
m[13] = 'B'
- // 13 14
+ // 13 14
m[gint()] = gbyte(), false
if _, present := m[13]; present {
- panicln("bad map removal")
+ println("bad map removal")
+ panic("fail")
}
c := make(chan byte, 1)
c <- 'C'
- // 15 16
+ // 15 16
*f(), p1 = <-e1(c, 16)
- // 17 18
+ // 17 18
*f(), p2 = <-e1(c, 18)
a[17] += '0'
if !p1 || p2 {
- panicln("bad chan check", i, p1, p2)
+ println("bad chan check", i, p1, p2)
+ panic("fail")
}
s1 := S1{'D'}
s2 := S2{'E'}
var iv I
- // 19 20
+ // 19 20
*e3(&iv, 19), p1 = e2(s1, 20).(I)
- // 21 22
+ // 21 22
*e3(&iv, 21), p2 = e2(s2, 22).(I)
if !p1 || p2 {
- panicln("bad interface check", i, p1, p2)
+ println("bad interface check", i, p1, p2)
+ panic("fail")
}
s := string(a[0:i])
if s != "def ii A 0 C 0 " {
- panicln("bad array results:", s)
+ println("bad array results:", s)
+ panic("fail")
}
}