Comment 3 for bug 1051847

Revision history for this message
Charlie Poole (charlie.poole) wrote :

It's clear that the stack overflow is bad and should be fixed.

Simone's comments introduce another issue around equality testing between two arrays or collections, which are potentially nested. One way to handle all three examples is to detect the recursion and return an error result. Note this is not the same as a Failure, since both
   Assert.That(array1, Is.EqualTo(array2));
and
   Assert.That(array1, Is.Not.EqualTo(array2));
would return errors - neither of them could succeed.

OTOH, if we think that actually making the comparison is reasonable, I think they should all pass. But implementation is a bit of an issue. We would need to keep track of all comparisons made so far, as a list of pairs of object references. This adds overhead that is generally not needed.

Personally, I'd rather not allow comparison of recursive arrays (and structures) at all, unless somebody can come up with a real-world example that requires it. If we had to do it, then I would want the user to mark all assertions that are potentially recursive to avoid the overhead, for example:
  Assert.That(array1, Is.EqualTo(array2).Recursive);

Charlie