making setting immutables an error
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9626 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
e284fcbf02
commit
bc08e0f335
6 changed files with 90 additions and 39 deletions
|
|
@ -55,15 +55,20 @@ example.print_vars()
|
|||
print "\nNow I'm going to try and modify some read only variables";
|
||||
|
||||
print " Tring to set 'path' to 'Whoa!'";
|
||||
example.path = "Whoa!"
|
||||
print " This request was silently ignored by Lua. "
|
||||
print " But the data has not been changed"
|
||||
print("path =", example.path)
|
||||
if pcall(function() example.path = "Whoa!" end)==true then
|
||||
print " Thats funny, it didn't give an error!"
|
||||
else
|
||||
print " It gave an error, as it should"
|
||||
end
|
||||
print(" Just checking the value: path =", example.path)
|
||||
|
||||
print " Trying to set 'status' to '0'";
|
||||
example.status = 0
|
||||
print " Again silently ignored"
|
||||
print("status =", example.status)
|
||||
if pcall(function() example.status = 0 end)==true then
|
||||
print " Thats funny, it didn't give an error!"
|
||||
else
|
||||
print " It gave an error, as it should"
|
||||
end
|
||||
print(" Just checking the value: status =", example.status)
|
||||
|
||||
|
||||
print "\nI'm going to try and update a structure variable.\n"
|
||||
|
|
|
|||
|
|
@ -85,8 +85,8 @@ struc=Structure()
|
|||
assert(type(struc.MemberString2)=="string") -- typemaps make this a string
|
||||
assert(type(struc.ConstMemberString)=="string")
|
||||
|
||||
-- set them
|
||||
struc.ConstMemberString="c" -- silently ignored
|
||||
-- set a const (should fail with error)
|
||||
assert(pcall(function () struc.ConstMemberString="c" end)==false)
|
||||
--print(struc.MemberString:data(),struc.MemberString2,struc.ConstMemberString:data())
|
||||
|
||||
--check type again
|
||||
|
|
@ -100,9 +100,9 @@ assert(type(struc.ConstMemberString)=="string")
|
|||
assert(type(li_std_string.Structure_StaticMemberString2)=="string")
|
||||
assert(type(li_std_string.Structure_ConstStaticMemberString)=="string")
|
||||
|
||||
-- try setting
|
||||
-- try setting (should fail with error)
|
||||
--li_std_string.Structure_StaticMemberString2='e'
|
||||
li_std_string.Structure_ConstStaticMemberString='f' -- silently ignored
|
||||
assert(pcall(function () li_std_string.Structure_ConstStaticMemberString='f' end)==false)
|
||||
--[[print(li_std_string.Structure_StaticMemberString:data(),
|
||||
li_std_string.Structure_StaticMemberString2,
|
||||
li_std_string.Structure_ConstStaticMemberString:data())]]
|
||||
|
|
@ -111,4 +111,3 @@ li_std_string.Structure_ConstStaticMemberString='f' -- silently ignored
|
|||
assert(type(li_std_string.Structure_StaticMemberString)=="string")
|
||||
assert(type(li_std_string.Structure_StaticMemberString2)=="string")
|
||||
assert(type(li_std_string.Structure_ConstStaticMemberString)=="string")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue