Skip to content

Commit afdb7e6

Browse files
committed
tests: add TestReflectSetForEmbed
1 parent 6327c16 commit afdb7e6

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tests/misc_test.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -862,3 +862,29 @@ func TestVersion(t *testing.T) {
862862
t.Fatalf("Got: runtime.Version() returned %q. Want: a valid Go version.", got)
863863
}
864864
}
865+
866+
// https://github.com/gopherjs/gopherjs/issues/1163
867+
func TestReflectSetForEmbed(t *testing.T) {
868+
type Point struct {
869+
x int
870+
y int
871+
}
872+
type Embed struct {
873+
value bool
874+
point Point
875+
}
876+
type A struct {
877+
Embed
878+
}
879+
c := &A{}
880+
c.value = true
881+
c.point = Point{100, 200}
882+
in := reflect.ValueOf(c).Elem()
883+
v := reflect.New(in.Type())
884+
e := v.Elem()
885+
f0 := e.Field(0)
886+
e.Set(in)
887+
if e.Field(0) != f0 {
888+
t.Fatalf("relfect.Set got %v, want %v", f0, e.Field(0))
889+
}
890+
}

0 commit comments

Comments
 (0)