MCPcopy
hub / github.com/gopherjs/gopherjs / TestReflectSetForEmbed

Function TestReflectSetForEmbed

tests/misc_test.go:901–924  ·  view source on GitHub ↗

https://github.com/gopherjs/gopherjs/issues/1163

(t *testing.T)

Source from the content-addressed store, hash-verified

899
900// https://github.com/gopherjs/gopherjs/issues/1163
901func TestReflectSetForEmbed(t *testing.T) {
902 type Point struct {
903 x int
904 y int
905 }
906 type Embed struct {
907 value bool
908 point Point
909 }
910 type A struct {
911 Embed
912 }
913 c := &A{}
914 c.value = true
915 c.point = Point{100, 200}
916 in := reflect.ValueOf(c).Elem()
917 v := reflect.New(in.Type())
918 e := v.Elem()
919 f0 := e.Field(0)
920 e.Set(in)
921 if e.Field(0) != f0 {
922 t.Fatalf("reflect.Set got %v, want %v", f0, e.Field(0))
923 }
924}
925
926func TestAssignImplicitConversion(t *testing.T) {
927 type S struct{}

Callers

nothing calls this directly

Calls 5

TypeMethod · 0.65
ElemMethod · 0.45
NewMethod · 0.45
FieldMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…