explicitcall tests
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@9187 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
da0f95ec8f
commit
37005baff5
4 changed files with 262 additions and 0 deletions
57
Examples/test-suite/python/explicitcall_runme.py
Normal file
57
Examples/test-suite/python/explicitcall_runme.py
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
from explicitcall import *
|
||||
|
||||
|
||||
# Test classic usage of the %explicitcall - using base class method from derived class
|
||||
class Mother(Person):
|
||||
def talk(self):
|
||||
return Person.talkPerson(self)
|
||||
|
||||
class Daughter(Child):
|
||||
def talk(self):
|
||||
return Person.talkPerson(self) + ":" + Child.talkChild(self)
|
||||
|
||||
class GrandDaughter(GrandChild):
|
||||
def talk(self):
|
||||
return Person.talkPerson(self) + ":" + Child.talkChild(self) + ":" + GrandChild.talkBambino(self)
|
||||
|
||||
|
||||
gc = GrandChild()
|
||||
if (gc.talkPerson() != "Person"):
|
||||
raise RuntimeError, "Explicit Person"
|
||||
if (gc.talkChild() != "Child"):
|
||||
raise RuntimeError, "Explicit Child"
|
||||
if (gc.talkBambino() != "GrandChild"):
|
||||
raise RuntimeError, "Explicit GrandChild"
|
||||
|
||||
if (gc.talk() != "GrandChild"):
|
||||
raise RuntimeError, "virtual GrandChild"
|
||||
|
||||
|
||||
p = Mother()
|
||||
if (p.talk() != "Person"):
|
||||
raise RuntimeError, "Mother"
|
||||
|
||||
p = Daughter()
|
||||
if (p.talk() != "Person:Child"):
|
||||
raise RuntimeError, "Daughter"
|
||||
|
||||
p = GrandDaughter()
|
||||
if (p.talk() != "Person:Child:GrandChild"):
|
||||
raise RuntimeError, "GrandDaughter"
|
||||
|
||||
t = TemplateString()
|
||||
if (t.barTemplateString(0) != "Template"):
|
||||
raise RuntimeError, "Template"
|
||||
|
||||
td = TDerived()
|
||||
|
||||
if (td.barTDerived() != "TDerived"):
|
||||
raise RuntimeError, "TDerived TDerived()"
|
||||
if (td.barTemplateString() != "Template"):
|
||||
raise RuntimeError, "TDerived Template()"
|
||||
|
||||
if (td.barTDerived(0) != "TDerived"):
|
||||
raise RuntimeError, "TDerived TDerived(0)"
|
||||
if (td.barTemplateString(0) != "Template"):
|
||||
raise RuntimeError, "TDerived Template(0)"
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue