From: Dossy Date: 2002-08-29T11:59:42+09:00 Subject: Re: CompareByValue On 2002.08.29, Ryan King wrote: > On 2002.08.29, Dossy wrote: > > > [...] http://www.rubygarden.org/ruby?CompareByValue > > > I don't think my solution to make the test pass is a "hack" that > > just makes the test pass, but the whole class of tests involving > > recursion, to pass. > > It causes them to return "equal", yes. =) Hee. > I added two assert_not_equal's that I should have had originally. > Maybe I'll break down and just add some more thorough tests. I > was trying to keep the size down so the intention of the module > was clearer... but I guess that was a silly tradeoff. Add more tests. Please. ;-) This is a good exercise in expressing the minimal tests required to describe the behavior of CompareByValue. > Also, I noticed someone added a version that uses a global > variable to keep track of "seen"s. This version passes all > tests, but isn't thread-safe... which is a limitation I'd like to > overcome. We could easily fix it by using thread-specific > storage, but the more interesting question: How would we devise a > test that verifies the thread-safety? I suppose we could come up > with something involving Thread.pass... Create two threads, run a CompareByValue of the same two objects, one in each thread ... it might require some trickery to expose the bug (or, multiple test runs, whatnot). Of course, on a single-CPU machine, I'm not sure even this will work without cooperation of the code-under-test itself ... -- Dossy -- Dossy Shiobara mail: dossy@panoptic.com Panoptic Computer Network web: http://www.panoptic.com/ "He realized the fastest way to change is to laugh at your own folly -- then you can let go and quickly move on." (p. 70)