Additional static member variable testing for Python
This commit is contained in:
parent
6b2caca8b9
commit
9135ad72e2
2 changed files with 52 additions and 4 deletions
|
|
@ -22,5 +22,28 @@ public:
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%{
|
%{
|
||||||
int StaticMemberTest::static_int;
|
int StaticMemberTest::static_int = 99;
|
||||||
|
%}
|
||||||
|
|
||||||
|
%inline %{
|
||||||
|
struct StaticBase {
|
||||||
|
static int statty;
|
||||||
|
virtual ~StaticBase() {}
|
||||||
|
};
|
||||||
|
struct StaticDerived : StaticBase {
|
||||||
|
static int statty;
|
||||||
|
};
|
||||||
|
%}
|
||||||
|
|
||||||
|
%{
|
||||||
|
int StaticBase::statty = 11;
|
||||||
|
int StaticDerived::statty = 111;
|
||||||
|
%}
|
||||||
|
|
||||||
|
%inline %{
|
||||||
|
#ifdef SWIGPYTHON_BUILTIN
|
||||||
|
bool is_python_builtin() { return true; }
|
||||||
|
#else
|
||||||
|
bool is_python_builtin() { return false; }
|
||||||
|
#endif
|
||||||
%}
|
%}
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,31 @@ else:
|
||||||
StaticFunctionTest().static_func()
|
StaticFunctionTest().static_func()
|
||||||
StaticFunctionTest().static_func_2(1)
|
StaticFunctionTest().static_func_2(1)
|
||||||
StaticFunctionTest().static_func_3(1, 2)
|
StaticFunctionTest().static_func_3(1, 2)
|
||||||
StaticMemberTest.static_int = 10
|
|
||||||
if not StaticMemberTest.static_int == 10:
|
if is_python_builtin():
|
||||||
raise RuntimeError("static_int not 10")
|
if not StaticMemberTest.static_int == 99: raise RuntimeError("static_int not 99")
|
||||||
|
StaticMemberTest.static_int = 10
|
||||||
|
if not StaticMemberTest.static_int == 10: raise RuntimeError("static_int not 10")
|
||||||
|
|
||||||
|
if not StaticBase.statty == 11: raise RuntimeError("statty not 11")
|
||||||
|
if not StaticDerived.statty == 111: raise RuntimeError("statty not 111")
|
||||||
|
StaticBase.statty = 22
|
||||||
|
StaticDerived.statty = 222
|
||||||
|
if not StaticBase.statty == 22: raise RuntimeError("statty not 22")
|
||||||
|
if not StaticDerived.statty == 222: raise RuntimeError("statty not 222")
|
||||||
|
|
||||||
|
# Restore
|
||||||
|
StaticMemberTest.static_int = 99
|
||||||
|
StaticBase.statty = 11
|
||||||
|
StaticDerived.statty = 111
|
||||||
|
|
||||||
|
if not cvar.StaticMemberTest_static_int == 99: raise RuntimeError("cvar static_int not 99")
|
||||||
|
cvar.StaticMemberTest_static_int = 10
|
||||||
|
if not cvar.StaticMemberTest_static_int == 10: raise RuntimeError("cvar static_int not 10")
|
||||||
|
|
||||||
|
if not cvar.StaticBase_statty == 11: raise RuntimeError("cvar statty not 11")
|
||||||
|
if not cvar.StaticDerived_statty == 111: raise RuntimeError("cvar statty not 111")
|
||||||
|
cvar.StaticBase_statty = 22
|
||||||
|
cvar.StaticDerived_statty = 222
|
||||||
|
if not cvar.StaticBase_statty == 22: raise RuntimeError("cvar statty not 22")
|
||||||
|
if not cvar.StaticDerived_statty == 222: raise RuntimeError("cvar statty not 222")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue