On Sat, 15 Dec 2001, Kurt D. Starsinic wrote: > > my $foo = Foo->new; > > ok( defined $foo && $foo->isa('Foo') ); > > > > which rapidly gets tiresome. > > Or ok(UNIVERSAL::isa(Foo->new, 'Foo'));
Under 5.005 it spits out warnings if Foo->new returns undef. Plus you still don't get any useful diagnostics. You just know it failed and then you'll have to go back and add debugging print statements or use the debugger to figure out _why_ it failed (did Foo->new return undef, something blessed into a different class, an unblessed thing, etc). I recently converted a rather large test suite (for Alzabo, 600+ unique tests or so) to use Test::More. Doing so helped me do several things: 1. Break down what I was testing into smaller units. Where I used to have things like: ok( @foo && defined $foo[0] && $foo[0]->name eq 'bob' ); I now have: is( @foo, 2, "expect two elements from bar() call" ); isa_ok( $foo[0], "Frobnigator" ); is( $foo[0]->name, 'bob', "the frobnigator should be named 'bob'" ); The presence of these similar but slightly different utility functions helped me really think about exactly what I should be testing. 2. Diagnosing new failures. The diagnostics are such that I rarely have to go back and add print statements or use the debugger. I know _why_ things are failing right away, which is better than simply knowing that they failed for some reason or other. 3. Removed liable to break support code bits that were being repeated everywhere. So in the end I have more tests, which are easier to diagnose, with less support code that I have to maintain. This is good because Alzabo is very complicated as it is and the tests have enough weird life support to do things like test against different RDBMS backends and such. Anything I don't have to write makes me happier. And if there's a problem with the testing code, I can report the bug to Schwern rather than fixing it in my five test suites where I copied the code around. Ok, so that's a bit off the topic of "why use isa_ok()" but I just don't see why people seem to object to the use of Test::More in the core Perl tests. I can't see how it couldn't help improve the quality of the tests while providing a standardized way to do the things that all the tests do anyway. -dave /*================== www.urth.org We await the New Sun ==================*/