-- $LastChangedDate: 2008-12-16 12:07:45 -0500 (Tue, 16 Dec 2008) $
-- Tests lib.lua

dofile( "../lib.lua" )

--------------------------------------------------------------------------------
-- Test lib.NewInstance(), lib.DESTROY().

print( "Testing lib.DESTROY()." )

Class = { }

destroyCalled = false

function Class:new()
	self = lib.NewInstance( Class )
	self.name = "Class"
	return self
end

function Class:destroy()
	-- Test that lib.DESTROY() passed self to this method.
	print( "Class:destroy() called." )
	assert( self )
	assert( self.name == "Class" )
	destroyCalled = true
end

container = { }
container.object = Class:new()
assert( container.object.name == "Class" )

-- Test lib.DESTROY().
lib.DESTROY( container, "object" )
assert( not container.object )  -- lib.DESTROY should nilify member
assert( destroyCalled )  -- destroy() should be called

print( "lib.DESTROY() passed." )
