Tagged: equality

Debugging F# NUnit equals for mixed type tuples

Twitter user Richard Dalton asked a great question recently:

Twitter question

And after a bit more digging he then mentioned

Twitter question

Interesting. I downloaded the NUnit source and saw this:

public bool AreEqual(object x, object y, ref Tolerance tolerance)
{
    this.failurePoints = new List<FailurePoint>();

    if (x == null && y == null)
        return true;

    if (x == null || y == null)
        return false;

    if (object.ReferenceEquals(x, y))
        return true;

    Type xType = x.GetType();
    Type yType = y.GetType();

    EqualityAdapter externalComparer = GetExternalComparer(x, y);
    if (externalComparer != null)
        return externalComparer.AreEqual(x, y);

    if (xType.IsArray && yType.IsArray && !compareAsCollection)
        return ArraysEqual((Array)x, (Array)y, ref tolerance);

    if (x is IDictionary && y is IDictionary)
        return DictionariesEqual((IDictionary)x, (IDictionary)y, ref tolerance);

    //if (x is ICollection && y is ICollection)
    //    return CollectionsEqual((ICollection)x, (ICollection)y, ref tolerance);

    if (x is IEnumerable && y is IEnumerable && !(x is string && y is string))
        return EnumerablesEqual((IEnumerable)x, (IEnumerable)y, ref tolerance);

    if (x is string && 
Read more