You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update assert to compare data structures that are isomorphically equal (such as a Tree, Trie, etc) to one another, but not equal by value or reference.
Proposed solution
Define an Equal and Diff interface that structures can implement that the require/assert package will check on equality assertion (e.g. require.Equal(t, expected, actual)) rather than using DeepEqual.
We are definately not going to change Equal to compare values any differently to how it does today, mostly because it is a breaking change.
Partly also because changing the definition of "equal" has led to issues before, as with the EqualValues assertion's problems. I'm also concerned that types will unintentionally satisfy this interface, time.Time from the standard library has an Equal method and it does not mean that the instances are equal, only that they represent the same instant.
Is there a way of proposing this as a compatible change with a reasonable level of safetly?
Description
Update
assert
to compare data structures that are isomorphically equal (such as a Tree, Trie, etc) to one another, but not equal by value or reference.Proposed solution
Define an
Equal
andDiff
interface that structures can implement that therequire
/assert
package will check on equality assertion (e.g.require.Equal(t, expected, actual)
) rather than usingDeepEqual
.Use case
Currently, the Cilium codebase uses a
require.Truef
as a workaround, calling into a customEquals
method and a customDiff
method.The text was updated successfully, but these errors were encountered: