Skip to content

Commit

Permalink
deepequal: tests, and treat nils as equal.
Browse files Browse the repository at this point in the history
  • Loading branch information
warpfork committed Sep 30, 2021
1 parent fdc808c commit 79a0220
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion datamodel/equal.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ package datamodel
// It is generally not recommended to call DeepEqual on ADL nodes.
func DeepEqual(x, y Node) bool {
if x == nil || y == nil {
return false
return x == y
}
xk, yk := x.Kind(), y.Kind()
if xk != yk {
Expand Down
2 changes: 2 additions & 0 deletions datamodel/equal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ var deepEqualTests = []struct {
// Repeated basicnode.New invocations might return different pointers.
{"SameNodeDiffPointer", basic.NewString("same"), basic.NewString("same"), true},

{"NilVsNil", nil, nil, true},
{"NilVsNull", nil, datamodel.Null, false},
{"SameKindNull", datamodel.Null, datamodel.Null, true},
{"DiffKindNull", datamodel.Null, datamodel.Absent, false},
{"SameKindBool", basic.NewBool(true), basic.NewBool(true), true},
Expand Down

0 comments on commit 79a0220

Please sign in to comment.