On Sun, Dec 16, 2001 at 09:30:18PM -0500, Benjamin Goldberg wrote: > Suppose we have RandomThing->new which randomly returns an instance of > one of a few dozen different classes, which have no relation at all with > each other except a common interface.
In such an odd case, don't use isa_ok(). Simp. > I think that if "all" we know about the returned type is that it is > supposed to provide some specific interface, it would be more robust to > test that the returned thing actually *does* provide the interface. As the ratio of constructors which return objects of random classes to those which produce something a bit more predictable is tiny, I'm not going to start assuming every constructor produces weird objects. Its more robust to do both. Check you got the right type and check the interface. On the off chance that the internals change to start producing randomly typed, yet interface conforming, objects, just change the tests. PS Do you know of anything that does return unpredictably typed objects? -- Michael G. Schwern <[EMAIL PROTECTED]> http://www.pobox.com/~schwern/ Perl Quality Assurance <[EMAIL PROTECTED]> Kwalitee Is Job One 36 haikus would scare the shit out of me. Thank goodness for paste! -- Schwern