]> Cypherpunks repositories - gostls13.git/commitdiff
reflect: test that PtrTo returns types that match program types
authorIan Lance Taylor <iant@golang.org>
Sat, 4 Feb 2012 01:36:25 +0000 (17:36 -0800)
committerIan Lance Taylor <iant@golang.org>
Sat, 4 Feb 2012 01:36:25 +0000 (17:36 -0800)
The gccgo compiler was failing this test.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/5631046

src/pkg/reflect/all_test.go

index 63b127d1029e1c9fd7294e16f3372e64dea278a8..8ae977912b3d0206610a95e75bad3cd7ada554c8 100644 (file)
@@ -1528,6 +1528,18 @@ func TestAddr(t *testing.T) {
        if p.X != 4 {
                t.Errorf("Addr.Elem.Set valued to set value in top value")
        }
+
+       // Verify that taking the address of a type gives us a pointer
+       // which we can convert back using the usual interface
+       // notation.
+       var s struct {
+               B *bool
+       }
+       ps := ValueOf(&s).Elem().Field(0).Addr().Interface()
+       *(ps.(**bool)) = new(bool)
+       if s.B == nil {
+               t.Errorf("Addr.Interface direct assignment failed")
+       }
 }
 
 func noAlloc(t *testing.T, n int, f func(int)) {