add FieldByName to the interface of reflect.StructType

R=rsc
DELTA=34  (33 added, 0 deleted, 1 changed)
OCL=31752
CL=31754
This commit is contained in:
Rob Pike 2009-07-16 18:21:14 -07:00
parent 1399badb02
commit a93c5c8550
2 changed files with 34 additions and 1 deletions

View file

@ -214,9 +214,18 @@ func TestAll(t *testing.T) { // TODO(r): wrap up better
styp := etyp.(*StructType);
f := styp.Field(0);
testType(t, 5, f.Type, "chan *int32");
f = styp.Field(1);
f, present := styp.FieldByName("d");
if !present {
t.Errorf("FieldByName says present field is absent");
}
testType(t, 6, f.Type, "float32");
f, present = styp.FieldByName("absent");
if present {
t.Errorf("FieldByName says absent field is present");
}
typ = Typeof(([32]int32)(nil));
testType(t, 7, typ, "[32]int32");
testType(t, 8, typ.(*ArrayType).Elem(), "int32");