MCPcopy
hub / github.com/gopherjs/gopherjs / TestCallingJsField

Function TestCallingJsField

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

Source from the content-addressed store, hash-verified

206}
207
208func TestCallingJsField(t *testing.T) {
209 a := &StructWithJsField1{Object: js.Global.Get("Array").New(100)}
210 b := &StructWithJsField2{object: js.Global.Get("Array").New(100)}
211 a.SetIndex(3, 123)
212 b.object.SetIndex(3, 123)
213 f := a.Slice
214 a2 := a.Slice(2, 44)
215 b2 := b.Slice(2, 44)
216 c2 := f(2, 44)
217 if len(a2) != 42 || len(b2) != 42 || len(c2) != 42 || a2[1] != 123 || b2[1] != 123 || c2[1] != 123 {
218 t.Fail()
219 }
220}
221
222func TestReflectionOnJsField(t *testing.T) {
223 a := StructWithJsField1{Object: js.Global.Get("Array").New(42)}

Callers

nothing calls this directly

Calls 4

GetMethod · 0.65
NewMethod · 0.45
SetIndexMethod · 0.45
SliceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…