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 -- You received this bug notification because you are a member of NUnit Developers, which is subscribed to NUnit V2. https://bugs.launchpad.net/bugs/1051847 Title: self contained item in array causes stack overflow Status in NUnit V2 Test Framework: Confirmed Bug description: using System.Collections; using System.Collections.Generic; using NUnit.Framework; [TestFixture] public class Reproduction { class SelfContainer : IEnumerable { public IEnumerator GetEnumerator() { yield return this; } } [Test] public void SelfContainedItemFoundInArray() { var item = new SelfContainer(); var items = new SelfContainer[] { new SelfContainer(), item }; // work around Assert.True(((ICollection<SelfContainer>)items).Contains(item)); // causes StackOverflowException Assert.Contains(item, items); } } Reproduced in NUnit 2.6.1 See also bug #491300 To manage notifications about this bug go to: https://bugs.launchpad.net/nunitv2/+bug/1051847/+subscriptions _______________________________________________ Mailing list: https://launchpad.net/~nunit-core Post to : [email protected] Unsubscribe : https://launchpad.net/~nunit-core More help : https://help.launchpad.net/ListHelp

