> The purpose of isa_ok() is two fold:
>
> Check that a scalar contains an object
> Check that object is of the right class
I've recently started using it for more than constructors. Here's a
patch to the docs to encourage this:
Thanks,
xoxo,
Andy
--- More.pm Sat Jul 6 22:57:13 2002
+++ More-new.pm Sat Jul 6 23:06:44 2002
@@ -510,6 +510,25 @@
you'd like them to be more specific, you can supply an $object_name
(for example 'Test customer').
+isa_ok can be used for any place where you want to check a function's
+return value. For example:
+
+ my $file = new Foo::File( $filename );
+ isa_ok( $file, 'Foo::File', "Opened $filename" );
+
+ my $record = $file->next_record();
+ isa_ok( $record, 'Foo::Record', "Read a record" );
+
+You don't think of next_record() as a constructor, but you still want to
+ensure that the correct value is being returned.
+
+And of course, you don't have to test only your code. The more tests you
+write, the more stringent your checking:
+
+ # From a DBI program
+ my $row = $dbh->fetch;
+ isa_ok( $row, 'ARRAY', "Got row from DB" );
+
=cut
sub isa_ok ($$;$) {
--
'Andy Lester [EMAIL PROTECTED]
Programmer/author petdance.com
Daddy parsley.org/quinn Jk'=~/.+/s;print((split//,$&)
[unpack'C*',"n2]3%+>\"34.'%&.'^%4+!o.'"])