MCPcopy
hub / github.com/gopherjs/gopherjs / TestReflectionOnJsField

Function TestReflectionOnJsField

tests/js_test.go:222–232  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

220}
221
222func TestReflectionOnJsField(t *testing.T) {
223 a := StructWithJsField1{Object: js.Global.Get("Array").New(42)}
224 wa := Wrapper1{StructWithJsField1: a}
225 if reflect.ValueOf(a).FieldByName("Length").Int() != 42 || reflect.ValueOf(&wa).Elem().FieldByName("WrapperLength").Int() != 42 {
226 t.Fail()
227 }
228 reflect.ValueOf(&wa).Elem().FieldByName("WrapperLength").Set(reflect.ValueOf(10))
229 if a.Length != 10 {
230 t.Fail()
231 }
232}
233
234func TestUnboxing(t *testing.T) {
235 a := StructWithJsField1{Object: js.Global.Get("Object").New()}

Callers

nothing calls this directly

Calls 5

GetMethod · 0.65
NewMethod · 0.45
IntMethod · 0.45
ElemMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…