#from thisRCPPy import *
from parfem.thisRCPPy import *

print '\ntestcase for thisRCP as set from C++:'
j = JDer()
assert j.getThisRCP() is not None
j = j.getThisRCP()
print j.foo();
del j

print '\ntestcase for thisRCP as from python extended class (using enable_shared_from_this):'
class KDer(K):
  def __init__(self):
    K.__init__(self)

k = KDer()
assert k.getThisRCP2() is not None
k2 = k.getThisRCP2()
if 1:
  print k2.foo();
  del k
  print 'with the `del k` statement the following statement will crash the program:';
  print k2.foo();
  print 'this line is never reached';
  #del k
  del k2

#assert k.getThisRCP() is not None


print '\ntestcase for thisRCP as from python extended class:'
class IDer(I):
  def __init__(self):
    I.__init__(self)
    self.setThisRCP(self)

i = IDer()
assert i.getThisRCP() is not None

