Commit 82a0188c authored by Ian Lance Taylor's avatar Ian Lance Taylor

reflect: fix TestAllocations now that interfaces hold only pointers

This test was failing but did not break the build because it
was not run when -test.short was used.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/157150043
parent 7b9c5ec2
......@@ -2502,10 +2502,21 @@ func TestAllocations(t *testing.T) {
noAlloc(t, 100, func(j int) {
var i interface{}
var v Value
i = 42 + j
// We can uncomment this when compiler escape analysis
// is good enough to see that the integer assigned to i
// does not escape and therefore need not be allocated.
//
// i = 42 + j
// v = ValueOf(i)
// if int(v.Int()) != 42+j {
// panic("wrong int")
// }
i = func(j int) int { return j }
v = ValueOf(i)
if int(v.Int()) != 42+j {
panic("wrong int")
if v.Interface().(func(int) int)(j) != j {
panic("wrong result")
}
})
}
......
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