add reflect.Typeof; test for and fix nil interface bug in DeepEqual

R=r
DELTA=40  (30 added, 2 deleted, 8 changed)
OCL=30742
CL=30753
This commit is contained in:
Russ Cox 2009-06-25 14:25:38 -07:00
parent 6af5775d74
commit 4866223c2e
3 changed files with 38 additions and 10 deletions

View file

@ -419,6 +419,7 @@ var deepEqualTests = []DeepEqualTest {
DeepEqualTest{ make([]int, 10), make([]int, 10), true },
DeepEqualTest{ &[3]int{ 1, 2, 3 }, &[3]int{ 1, 2, 3 }, true },
DeepEqualTest{ Basic{ 1, 0.5 }, Basic{ 1, 0.5 }, true },
DeepEqualTest{ os.Error(nil), os.Error(nil), true },
// Inequalities
DeepEqualTest{ 1, 2, false },
DeepEqualTest{ int32(1), int32(2), false },
@ -445,6 +446,16 @@ func TestDeepEqual(t *testing.T) {
}
}
func TestTypeof(t *testing.T) {
for i, test := range deepEqualTests {
v := NewValue(test.a);
typ := Typeof(test.a);
if typ != v.Type() {
t.Errorf("Typeof(%v) = %v, but NewValue(%v).Type() = %v", test.a, typ, test.a, v.Type());
}
}
}
func TestDeepEqualRecursiveStruct(t *testing.T) {
a, b := new(Recursive), new(Recursive);
*a = Recursive{ 12, a };