reflect: document and test TypeOf(nil)
Fixes #3549.
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6107047
diff --git a/src/pkg/reflect/all_test.go b/src/pkg/reflect/all_test.go
index 6bb0613..e331405 100644
--- a/src/pkg/reflect/all_test.go
+++ b/src/pkg/reflect/all_test.go
@@ -638,6 +638,7 @@
var deepEqualTests = []DeepEqualTest{
// Equalities
+ {nil, nil, true},
{1, 1, true},
{int32(1), int32(1), true},
{0.5, 0.5, true},
@@ -696,6 +697,10 @@
}
func TestTypeOf(t *testing.T) {
+ // Special case for nil
+ if typ := TypeOf(nil); typ != nil {
+ t.Errorf("expected nil type for nil value; got %v", typ)
+ }
for _, test := range deepEqualTests {
v := ValueOf(test.a)
if !v.IsValid() {