mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
reflect: document and test TypeOf(nil)
Fixes #3549. R=golang-dev, dsymonds CC=golang-dev https://golang.org/cl/6107047
This commit is contained in:
parent
0cc8ee9808
commit
53372903c7
2 changed files with 6 additions and 0 deletions
|
|
@ -638,6 +638,7 @@ var (
|
|||
|
||||
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 TestDeepEqual(t *testing.T) {
|
|||
}
|
||||
|
||||
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() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue