MCPcopy
hub / github.com/gopherjs/gopherjs / TestInternalizeStruct

Function TestInternalizeStruct

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

Source from the content-addressed store, hash-verified

306}
307
308func TestInternalizeStruct(t *testing.T) {
309 type Person struct {
310 Name string
311 Age int
312 }
313 var a, expected Person
314 expected = Person{Name: "foo", Age: 952}
315
316 js.Global.Set("return_person", func(p *Person) *Person {
317 if p == nil {
318 t.Fail()
319 return nil
320 }
321 a = *p
322 return p
323 })
324
325 js.Global.Call("eval", "return_person({Name: 'foo', Age: 952})")
326 if diff := cmp.Diff(a, expected); diff != "" {
327 t.Errorf("Mismatch (-want +got):\n%s", diff)
328 }
329}
330
331func TestInternalizeStructUnexportedFields(t *testing.T) {
332 type Person struct {

Callers

nothing calls this directly

Calls 2

SetMethod · 0.45
CallMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…