Add in runtime std::variable tests based on other language runtime tests. Might make some of the original type checking tests redundant.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@8611 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
ec5c6280bb
commit
a1c01cfedd
1 changed files with 29 additions and 11 deletions
|
|
@ -58,22 +58,40 @@ assert(ok==false and type(ex)=="userdata") -- failed & threw object
|
||||||
ok,ex=pcall(test_pointer_throw)
|
ok,ex=pcall(test_pointer_throw)
|
||||||
assert(ok==false and type(ex)=="userdata") -- failed & threw object
|
assert(ok==false and type(ex)=="userdata") -- failed & threw object
|
||||||
|
|
||||||
-- testing the structure:
|
-- testing std::string variables
|
||||||
|
-- Global variables
|
||||||
|
s = "initial string"
|
||||||
|
assert (li_std_string.GlobalString2 == "global string 2")
|
||||||
|
li_std_string.GlobalString2 = s
|
||||||
|
assert (li_std_string.GlobalString2 == s)
|
||||||
|
assert (li_std_string.ConstGlobalString == "const global string")
|
||||||
|
|
||||||
s=Structure()
|
-- Member variables
|
||||||
|
myStructure = Structure()
|
||||||
|
assert(myStructure.MemberString2 == "member string 2")
|
||||||
|
myStructure.MemberString2 = s
|
||||||
|
assert (myStructure.MemberString2 == s)
|
||||||
|
assert (myStructure.ConstMemberString == "const member string")
|
||||||
|
|
||||||
-- testing std::string
|
assert (li_std_string.Structure_StaticMemberString2 == "static member string 2")
|
||||||
assert(type(s.MemberString2)=="string") -- typemaps make this a string
|
li_std_string.Structure_StaticMemberString2 = s
|
||||||
assert(type(s.ConstMemberString)=="string")
|
assert (li_std_string.Structure_StaticMemberString2 == s)
|
||||||
|
assert (li_std_string.Structure_ConstStaticMemberString == "const static member string")
|
||||||
|
|
||||||
|
|
||||||
|
-- testing the structure (these are some old tests which predated the std::string variable tests above)
|
||||||
|
struc=Structure()
|
||||||
|
|
||||||
|
assert(type(struc.MemberString2)=="string") -- typemaps make this a string
|
||||||
|
assert(type(struc.ConstMemberString)=="string")
|
||||||
|
|
||||||
-- set them
|
-- set them
|
||||||
s.MemberString2="b" -- typemaps ok
|
struc.ConstMemberString="c" -- silently ignored
|
||||||
s.ConstMemberString="c" -- silently ignored
|
--print(struc.MemberString:data(),struc.MemberString2,struc.ConstMemberString:data())
|
||||||
--print(s.MemberString:data(),s.MemberString2,s.ConstMemberString:data())
|
|
||||||
|
|
||||||
--check type again
|
--check type again
|
||||||
assert(type(s.MemberString2)=="string") -- typemaps make this a string
|
assert(type(struc.MemberString2)=="string") -- typemaps make this a string
|
||||||
assert(type(s.ConstMemberString)=="string")
|
assert(type(struc.ConstMemberString)=="string")
|
||||||
|
|
||||||
-- for static types: they are really variables,
|
-- for static types: they are really variables,
|
||||||
-- so we must still use the module name
|
-- so we must still use the module name
|
||||||
|
|
@ -83,7 +101,7 @@ assert(type(li_std_string.Structure_StaticMemberString2)=="string")
|
||||||
assert(type(li_std_string.Structure_ConstStaticMemberString)=="string")
|
assert(type(li_std_string.Structure_ConstStaticMemberString)=="string")
|
||||||
|
|
||||||
-- try setting
|
-- try setting
|
||||||
li_std_string.Structure_StaticMemberString2='e'
|
--li_std_string.Structure_StaticMemberString2='e'
|
||||||
li_std_string.Structure_ConstStaticMemberString='f' -- silently ignored
|
li_std_string.Structure_ConstStaticMemberString='f' -- silently ignored
|
||||||
--[[print(li_std_string.Structure_StaticMemberString:data(),
|
--[[print(li_std_string.Structure_StaticMemberString:data(),
|
||||||
li_std_string.Structure_StaticMemberString2,
|
li_std_string.Structure_StaticMemberString2,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue