On Sun, Jun 30, 2002 at 05:37:14PM -0700, chromatic wrote:
> Here's a patch to the Test::Simple 0.45 distribution to make isa_ok() work with
> class names, not just objects.  It tries to respect custom isa() methods, as
> well.

The purpose of isa_ok() is two fold:

    Check that a scalar contains an object
    Check that object is of the right class

and it only exists because it's a very common test and you have to do the
above in several steps to get good diagnostics:

    ok( defined $obj,           'object is defined' );
    ok( ref $obj,               'object is a reference' );
    ok( $obj->isa('My::Thing'), 'object isa My::Thing' );

Whereas checking a class is much simpler

    ok( $class->isa('Whatever'), "$class isa Whatever" );

Worse, it adds an ambiguity into isa_ok() with the small possiblity that
$obj might contain a class string and cause a false positive.

So I'm not convinced.  Why did you find it useful?


-- 
This sig file temporarily out of order.

Reply via email to