From: Ian Lance Taylor Date: Mon, 20 Oct 2014 18:10:03 +0000 (-0700) Subject: reflect: fix TestAllocations now that interfaces hold only pointers X-Git-Tag: go1.4beta1~74 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=82a0188c88bd7bb0fbf31f10157b77beb2195594;p=gostls13.git 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 --- diff --git a/src/reflect/all_test.go b/src/reflect/all_test.go index 40eae0364c..268a9e319f 100644 --- a/src/reflect/all_test.go +++ b/src/reflect/all_test.go @@ -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") } }) }