Michael G Schwern <[EMAIL PROTECTED]> writes: > On Sun, Dec 16, 2001 at 02:41:31PM +0000, Piers Cawley wrote: >> > The equivalent code without isa_ok() would be: >> > >> > my $foo = Foo->new; >> > ok( $foo->isa('Foo') ); >> > >> > except should $foo be unblessed or undef that will explode. You have >> > to start doing things like: >> > >> > my $foo = Foo->new; >> > ok( defined $foo && $foo->isa('Foo') ); >> > >> > which rapidly gets tiresome. It also provides you little information >> > about what value $foo held that caused it to fail. >> >> What's wrong with >> >> ok ( eval { $foo->isa('Foo') } ); >> >> or even: >> >> ok (eval { ref($foo) && $foo->isa('Foo') }); > > As Kurt already pointed out, you can do: > > ok( UNIVERSAL::isa($foo, 'Foo') ); > > but if it fails you have no idea what $foo was.
No you can't. Not if you've overridden isa anywhere. (Which is perfectly possible.) -- Piers "It is a truth universally acknowledged that a language in possession of a rich syntax must be in need of a rewrite." -- Jane Austen?