| 220 | } |
| 221 | |
| 222 | func 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 | |
| 234 | func TestUnboxing(t *testing.T) { |
| 235 | a := StructWithJsField1{Object: js.Global.Get("Object").New()} |