I'm creating a test suite for an XOTcl class I'm writing, and I want to test this sequence:
(1) MyClass is undefined (initial state) --- package require MyClass succeeds (2) MyClass is defined (expected state after loading the package) (3) MyClass isa ::xotcl::Class (4) MyClass has methods x, y, z
However, I am not having any luck in testing #1 and #2. Is there any kind of introspection that can help me determine if a class is defined? Using [info exists MyClass] doesn't seem to work.
Thanks,
-- Adam
Adam Turoff wrote:
I'm creating a test suite for an XOTcl class I'm writing, and I want to test this sequence:
(1) MyClass is undefined (initial state) --- package require MyClass succeeds (2) MyClass is defined (expected state after loading the package) (3) MyClass isa ::xotcl::Class (4) MyClass has methods x, y, z
However, I am not having any luck in testing #1 and #2. Is there any kind of introspection that can help me determine if a class is defined? Using [info exists MyClass] doesn't seem to work.
Try it simple, a defined class is just a tcl command:
if {[llength [info commands MyClass]]} { puts "Found MyClass" } else { puts "Not Found" }
Michael
Adam,
you can ask any XOTcl object (e.g. Object) if another identifier is the name of an object. e.g.:
% Object isobject MyClass 0
You can also ask any object whether it is a class:
% Class create MyClass ::MyClass % Object isobject MyClass 1 % MyClass isclass 1 %
an object would return 0 in this example:
% Object create m ::m % Object isobject m 1 %m isclass 0
see langRef for more details ...
--Uwe
Adam Turoff wrote:
I'm creating a test suite for an XOTcl class I'm writing, and I want to test this sequence:
(1) MyClass is undefined (initial state) --- package require MyClass succeeds (2) MyClass is defined (expected state after loading the package) (3) MyClass isa ::xotcl::Class (4) MyClass has methods x, y, z
However, I am not having any luck in testing #1 and #2. Is there any kind of introspection that can help me determine if a class is defined? Using [info exists MyClass] doesn't seem to work.
Thanks,
-- Adam _______________________________________________ Xotcl mailing list - Xotcl@alice.wu-wien.ac.at http://alice.wu-wien.ac.at/mailman/listinfo/xotcl
On Fri, 25 Jun 2004 16:19:16 +0200, Uwe Zdun uwe.zdun@wu-wien.ac.at wrote:
% Object isobject MyClass 0 % Class create MyClass ::MyClass % Object isobject MyClass 1 % MyClass isclass 1
Works great. Thanks.
-- Adam