summaryrefslogtreecommitdiff
path: root/Examples/test-suite/lua
diff options
context:
space:
mode:
Diffstat (limited to 'Examples/test-suite/lua')
-rw-r--r--Examples/test-suite/lua/Makefile.in64
-rw-r--r--Examples/test-suite/lua/abstract_access_runme.lua17
-rw-r--r--Examples/test-suite/lua/cpp_basic_runme.lua64
-rw-r--r--Examples/test-suite/lua/disown_runme.lua12
-rw-r--r--Examples/test-suite/lua/dynamic_cast_runme.lua15
-rw-r--r--Examples/test-suite/lua/enums_runme.lua20
-rw-r--r--Examples/test-suite/lua/exception_order_runme.lua45
-rw-r--r--Examples/test-suite/lua/exception_partial_info_runme.lua12
-rw-r--r--Examples/test-suite/lua/import.lua28
-rw-r--r--Examples/test-suite/lua/import_nomodule_runme.lua14
-rw-r--r--Examples/test-suite/lua/imports_runme.lua28
-rw-r--r--Examples/test-suite/lua/li_carrays_runme.lua29
-rw-r--r--Examples/test-suite/lua/li_std_except_runme.lua16
-rw-r--r--Examples/test-suite/lua/li_std_pair_runme.lua34
-rw-r--r--Examples/test-suite/lua/li_std_string_runme.lua113
-rw-r--r--Examples/test-suite/lua/li_std_vector_runme.lua66
-rw-r--r--Examples/test-suite/lua/li_typemaps_runme.lua40
-rw-r--r--Examples/test-suite/lua/member_pointer_runme.lua43
-rw-r--r--Examples/test-suite/lua/multi_import_runme.lua16
-rw-r--r--Examples/test-suite/lua/newobject1_runme.lua16
-rw-r--r--Examples/test-suite/lua/newobject2_runme.lua16
-rw-r--r--Examples/test-suite/lua/operator_overload_runme.lua157
-rw-r--r--Examples/test-suite/lua/overload_simple_runme.lua55
-rw-r--r--Examples/test-suite/lua/overload_template_fast_runme.lua81
-rw-r--r--Examples/test-suite/lua/overload_template_runme.lua81
-rw-r--r--Examples/test-suite/lua/pointer_reference_runme.lua11
-rw-r--r--Examples/test-suite/lua/primitive_ref_runme.lua32
-rw-r--r--Examples/test-suite/lua/ret_by_value_runme.lua6
-rw-r--r--Examples/test-suite/lua/sizet_runme.lua9
-rw-r--r--Examples/test-suite/lua/smart_pointer_overload_runme.lua14
-rw-r--r--Examples/test-suite/lua/template_default_arg_runme.lua63
-rw-r--r--Examples/test-suite/lua/voidtest_runme.lua37
32 files changed, 1254 insertions, 0 deletions
diff --git a/Examples/test-suite/lua/Makefile.in b/Examples/test-suite/lua/Makefile.in
new file mode 100644
index 0000000..0ddc86a
--- /dev/null
+++ b/Examples/test-suite/lua/Makefile.in
@@ -0,0 +1,64 @@
+#######################################################################
+# Makefile for lua test-suite
+#######################################################################
+
+LANGUAGE = lua
+LUA = @LUABIN@
+SCRIPTSUFFIX = _runme.lua
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+top_builddir = @top_builddir@
+
+# sorry, currently very few test cases work/have been written
+
+#CPP_TEST_CASES += \
+# cnum
+
+#C_TEST_CASES += \
+# file_test \
+# nondynamic
+
+
+include $(srcdir)/../common.mk
+
+# Overridden variables here
+LIBS = -L.
+
+# Custom tests - tests with additional commandline options
+# none!
+
+# Rules for the different types of tests
+%.cpptest:
+ $(setup)
+ +$(swig_and_compile_cpp)
+ $(run_testcase)
+
+%.ctest:
+ $(setup)
+ +$(swig_and_compile_c)
+ $(run_testcase)
+
+%.multicpptest:
+ $(setup)
+ +$(swig_and_compile_multi_cpp)
+ $(run_testcase)
+
+# Runs the testcase. A testcase is only run if
+# a file is found which has _runme.lua appended after the testcase name.
+run_testcase = \
+ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
+ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(LUA) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
+ fi
+
+# Clean: (does nothing, we dont generate extra lua code)
+%.clean:
+
+
+clean:
+ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile lua_clean
+
+cvsignore:
+ @echo '*wrap* *.so *.dll *.exp *.lib'
+ @echo Makefile
+ @for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do echo $$i.lua; done
+ @for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do if grep -q $${i}_runme.lua CVS/Entries ; then echo $${i}_runme.lua; fi; done
diff --git a/Examples/test-suite/lua/abstract_access_runme.lua b/Examples/test-suite/lua/abstract_access_runme.lua
new file mode 100644
index 0000000..b9f44cf
--- /dev/null
+++ b/Examples/test-suite/lua/abstract_access_runme.lua
@@ -0,0 +1,17 @@
+require("import") -- the import fn
+import("abstract_access") -- import code
+
+-- catch "undefined" global variables
+setmetatable(getfenv(),{__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
+
+-- trying to instantiate pure virual classes
+-- should fail
+assert(pcall(abstract_access.A)==false)
+assert(pcall(abstract_access.B)==false)
+assert(pcall(abstract_access.C)==false)
+
+-- instantiate object
+d=abstract_access.D()
+
+--call fn
+assert(d:do_x()==1)
diff --git a/Examples/test-suite/lua/cpp_basic_runme.lua b/Examples/test-suite/lua/cpp_basic_runme.lua
new file mode 100644
index 0000000..b63b89c
--- /dev/null
+++ b/Examples/test-suite/lua/cpp_basic_runme.lua
@@ -0,0 +1,64 @@
+require("import") -- the import fn
+import("cpp_basic") -- import code
+cb=cpp_basic -- renaming import
+
+-- catch "undefined" global variables
+setmetatable(getfenv(),{__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
+
+f=cb.Foo(4)
+assert(f.num==4)
+f.num=-17
+assert(f.num==-17)
+
+b=cb.Bar()
+
+b.fptr=f
+assert(b.fptr.num==-17)
+assert(b:test(-3,b.fptr)==-5)
+f.num=12
+assert(b.fptr.num==12)
+
+assert(b.fref.num==-4)
+assert(b:test(12,b.fref)==23)
+
+-- references don't take ownership, so if we didn't define this here it might get garbage collected
+f2=cb.Foo(23)
+b.fref=f2
+assert(b.fref.num==23)
+assert(b:test(-3,b.fref)==35)
+
+assert(b.fval.num==15)
+assert(b:test(3,b.fval)==33)
+b.fval=cb.Foo(-15) -- this is safe as it is copied into the C++
+assert(b.fval.num==-15)
+assert(b:test(3,b.fval)==-27)
+
+f3=b:testFoo(12,b.fref)
+assert(f3.num==32)
+
+-- now test global
+f4=cb.Foo(6)
+cb.Bar_global_fptr=f4
+assert(cb.Bar_global_fptr.num==6)
+f4.num=8
+assert(cb.Bar_global_fptr.num==8)
+
+assert(cb.Bar_global_fref.num==23)
+cb.Bar_global_fref=cb.Foo(-7) -- this will set the value
+assert(cb.Bar_global_fref.num==-7)
+
+assert(cb.Bar_global_fval.num==3)
+cb.Bar_global_fval=cb.Foo(-34)
+assert(cb.Bar_global_fval.num==-34)
+
+-- Now test member function pointers
+func1_ptr=cb.get_func1_ptr()
+func2_ptr=cb.get_func2_ptr()
+f.num=4
+assert(f:func1(2)==16)
+assert(f:func2(2)==-8)
+
+f.func_ptr=func1_ptr
+assert(cb.test_func_ptr(f,2)==16)
+f.func_ptr=func2_ptr
+assert(cb.test_func_ptr(f,2)==-8)
diff --git a/Examples/test-suite/lua/disown_runme.lua b/Examples/test-suite/lua/disown_runme.lua
new file mode 100644
index 0000000..2707589
--- /dev/null
+++ b/Examples/test-suite/lua/disown_runme.lua
@@ -0,0 +1,12 @@
+require("import") -- the import fn
+import("disown") -- import code
+
+-- catch "undefined" global variables
+setmetatable(getfenv(),{__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
+
+for x=0,100 do
+ a=disown.A()
+ b=disown.B()
+ b:acquire(a)
+end
+collectgarbage() -- this will double delete unless the memory is managed properly
diff --git a/Examples/test-suite/lua/dynamic_cast_runme.lua b/Examples/test-suite/lua/dynamic_cast_runme.lua
new file mode 100644
index 0000000..6e0a1d2
--- /dev/null
+++ b/Examples/test-suite/lua/dynamic_cast_runme.lua
@@ -0,0 +1,15 @@
+require("import") -- the import fn
+import("dynamic_cast") -- import code
+
+f = dynamic_cast.Foo()
+b = dynamic_cast.Bar()
+
+x = f:blah()
+y = b:blah()
+
+-- swig_type is a swiglua specific function which gets the swig_type_info's name
+assert(swig_type(f)==swig_type(x))
+assert(swig_type(b)==swig_type(y))
+
+-- the real test: is y a Foo* or a Bar*?
+assert(dynamic_cast.do_test(y)=="Bar::test")
diff --git a/Examples/test-suite/lua/enums_runme.lua b/Examples/test-suite/lua/enums_runme.lua
new file mode 100644
index 0000000..f96331c
--- /dev/null
+++ b/Examples/test-suite/lua/enums_runme.lua
@@ -0,0 +1,20 @@
+require("import") -- the import fn
+import("enums") -- import lib
+
+-- catch "undefined" global variables
+setmetatable(getfenv(),{__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
+
+-- check values
+assert(enums.CSP_ITERATION_FWD==0)
+assert(enums.CSP_ITERATION_BWD==11)
+assert(enums.ABCDE==0)
+assert(enums.FGHJI==1)
+assert(enums.boo==0)
+assert(enums.hoo==5)
+assert(enums.globalinstance1==0)
+assert(enums.globalinstance2==1)
+assert(enums.globalinstance3==30)
+assert(enums.AnonEnum1==0)
+assert(enums.AnonEnum2==100)
+
+-- no point in checking fns, C will allow any value
diff --git a/Examples/test-suite/lua/exception_order_runme.lua b/Examples/test-suite/lua/exception_order_runme.lua
new file mode 100644
index 0000000..e5caa83
--- /dev/null
+++ b/Examples/test-suite/lua/exception_order_runme.lua
@@ -0,0 +1,45 @@
+-- demo of lua swig capacilities (operator overloading)
+require("import") -- the import fn
+import("exception_order") -- import lib into global
+eo=exception_order --alias
+
+-- catching undefined variables
+setmetatable(getfenv(),{__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
+
+a = eo.A()
+
+function try1()
+ a:foo()
+end
+
+function try2()
+ a:bar()
+end
+
+function try3()
+ a:foobar()
+end
+
+-- the following code used to work
+-- but now no longer works, as the lua bindings don't throw objects any more
+-- all objects are converted to string & thrown
+-- it could be made to work, if E1 & E2 were thrown by value (see lua.swg)
+--[[
+ok,ex=pcall(try1)
+print(ok,ex)
+assert(ok==false and swig_type(ex)==swig_type(eo.E1()))
+
+ok,ex=pcall(try2)
+assert(ok==false and swig_type(ex)==swig_type(eo.E2()))
+]]
+-- this new code does work, but has to look at the string
+ok,ex=pcall(try1)
+assert(ok==false and ex=="object exception:E1")
+
+ok,ex=pcall(try2)
+assert(ok==false and ex=="object exception:E2")
+
+-- the SWIG_exception is just an error string
+ok,ex=pcall(try3)
+assert(ok==false and type(ex)=="string")
+
diff --git a/Examples/test-suite/lua/exception_partial_info_runme.lua b/Examples/test-suite/lua/exception_partial_info_runme.lua
new file mode 100644
index 0000000..fb0e514
--- /dev/null
+++ b/Examples/test-suite/lua/exception_partial_info_runme.lua
@@ -0,0 +1,12 @@
+require("import") -- the import fn
+import("exception_partial_info") -- import code
+
+-- catch "undefined" global variables
+setmetatable(getfenv(),{__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
+
+imp=exception_partial_info.Impl()
+
+-- trying to call throwing methods
+-- should fail
+assert(pcall(function() imp:f1() end)==false)
+assert(pcall(function() imp:f2() end)==false)
diff --git a/Examples/test-suite/lua/import.lua b/Examples/test-suite/lua/import.lua
new file mode 100644
index 0000000..eaab3b4
--- /dev/null
+++ b/Examples/test-suite/lua/import.lua
@@ -0,0 +1,28 @@
+-- import
+-- the lua 5.0 loading mechanism is rather poor & relies upon the loadlib() fn
+-- the lua 5.1 loading mechanism is simplicity itself
+-- for now we need a bridge which will use the correct verion
+
+function import_5_0(name)
+ -- imports the file into the program
+ -- for a module 'example'
+ -- this must load 'example.dll' or 'example.so'
+ -- and look for the fn 'luaopen_example()'
+ if rawget(_G,name)~=nil then return end -- module appears to be loaded
+
+ local lib=loadlib(name..'.dll','luaopen_'..name) or loadlib(name..'.so','luaopen_'..name)
+ assert(lib,"error loading module:"..name)
+
+ lib() -- execute the function: initalising the lib
+ assert(rawget(_G,name)~=nil,"no module table found")
+end
+
+function import_5_1(name)
+ require(name)
+end
+
+if string.sub(_VERSION,1,7)=='Lua 5.0' then
+ import=import_5_0
+else
+ import=import_5_1
+end \ No newline at end of file
diff --git a/Examples/test-suite/lua/import_nomodule_runme.lua b/Examples/test-suite/lua/import_nomodule_runme.lua
new file mode 100644
index 0000000..947aceb
--- /dev/null
+++ b/Examples/test-suite/lua/import_nomodule_runme.lua
@@ -0,0 +1,14 @@
+require("import") -- the import fn
+import("import_nomodule") -- import code
+
+-- catch "undefined" global variables
+setmetatable(getfenv(),{__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
+
+f = import_nomodule.create_Foo()
+import_nomodule.test1(f,42)
+import_nomodule.delete_Foo(f)
+
+b = import_nomodule.Bar()
+import_nomodule.test1(b,37)
+
+collectgarbage() \ No newline at end of file
diff --git a/Examples/test-suite/lua/imports_runme.lua b/Examples/test-suite/lua/imports_runme.lua
new file mode 100644
index 0000000..1509e17
--- /dev/null
+++ b/Examples/test-suite/lua/imports_runme.lua
@@ -0,0 +1,28 @@
+require("import") -- the import fn
+-- need to load two modules
+import("imports_a") -- import code
+import("imports_b") -- import code
+
+b=imports_b.B()
+b:hello() -- call member function in A which is in a different SWIG generated library.
+b:bye()
+
+assert (b:member_virtual_test(imports_a.A_memberenum1) == imports_a.A_memberenum2)
+assert (b:global_virtual_test(imports_a.globalenum1) == imports_a.globalenum2)
+
+imports_b.global_test(imports_a.A_memberenum1)
+
+--[[ B b = new B();
+ b.hello(); //call member function in A which is in a different SWIG generated library.
+
+ B b = new B();
+ b.hello(); //call member function in A which is in a different SWIG generated library.
+ b.bye();
+
+ if (b.member_virtual_test(A.MemberEnum.memberenum1) != A.MemberEnum.memberenum2)
+ throw new Exception("Test 1 failed");
+ if (b.global_virtual_test(GlobalEnum.globalenum1) != GlobalEnum.globalenum2)
+ throw new Exception("Test 2 failed");
+
+ imports_b.global_test(A.MemberEnum.memberenum1);
+]]
diff --git a/Examples/test-suite/lua/li_carrays_runme.lua b/Examples/test-suite/lua/li_carrays_runme.lua
new file mode 100644
index 0000000..c54e36a
--- /dev/null
+++ b/Examples/test-suite/lua/li_carrays_runme.lua
@@ -0,0 +1,29 @@
+require("import") -- the import fn
+import("li_carrays") -- import code
+
+-- moving to global
+for k,v in pairs(li_carrays) do _G[k]=v end
+
+-- catch "undefined" global variables
+setmetatable(getfenv(),{__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
+
+-- Testing for %array_functions(int,intArray)
+ary = new_intArray(2)
+intArray_setitem(ary, 0, 0)
+intArray_setitem(ary, 1, 1)
+assert(intArray_getitem(ary, 0)==0)
+assert(intArray_getitem(ary, 1)==1)
+delete_intArray(ary)
+
+-- Testing for %array_class(double, doubleArray)
+d = doubleArray(10)
+d[0] = 7
+d[5] = d[0] + 3
+assert(d[5] + d[0] == 17)
+--print(d[5] + d[0])
+
+ptr = d:cast() -- to ptr
+d2 = doubleArray_frompointer(ptr) -- and back to array
+assert(d2[5] + d2[0] == 17)
+--print(d2[5] + d2[0])
+
diff --git a/Examples/test-suite/lua/li_std_except_runme.lua b/Examples/test-suite/lua/li_std_except_runme.lua
new file mode 100644
index 0000000..014368f
--- /dev/null
+++ b/Examples/test-suite/lua/li_std_except_runme.lua
@@ -0,0 +1,16 @@
+require("import") -- the import fn
+import("li_std_except") -- import code
+
+test = li_std_except.Test()
+-- under lua, all the std::exceptions are just turned to strings, so we are only checking that is fails
+assert(pcall(function() test:throw_bad_exception() end)==false)
+assert(pcall(function() test:throw_domain_error() end)==false)
+assert(pcall(function() test:throw_exception() end)==false)
+assert(pcall(function() test:throw_invalid_argument() end)==false)
+assert(pcall(function() test:throw_length_error() end)==false)
+assert(pcall(function() test:throw_logic_error() end)==false)
+assert(pcall(function() test:throw_out_of_range() end)==false)
+assert(pcall(function() test:throw_overflow_error() end)==false)
+assert(pcall(function() test:throw_range_error() end)==false)
+assert(pcall(function() test:throw_runtime_error() end)==false)
+assert(pcall(function() test:throw_underflow_error() end)==false)
diff --git a/Examples/test-suite/lua/li_std_pair_runme.lua b/Examples/test-suite/lua/li_std_pair_runme.lua
new file mode 100644
index 0000000..793eaa8
--- /dev/null
+++ b/Examples/test-suite/lua/li_std_pair_runme.lua
@@ -0,0 +1,34 @@
+require("import") -- the import fn
+import("li_std_pair") -- import code
+
+for k,v in pairs(li_std_pair) do _G[k]=v end -- move to global
+
+intPair = makeIntPair(7, 6)
+assert(intPair.first==7 and intPair.second==6)
+
+intPairPtr = makeIntPairPtr(7, 6)
+assert(intPairPtr.first==7 and intPairPtr.second==6)
+
+intPairRef = makeIntPairRef(7, 6)
+assert(intPairRef.first == 7 and intPairRef.second == 6)
+
+intPairConstRef = makeIntPairConstRef(7, 6)
+assert(intPairConstRef.first == 7 and intPairConstRef.second == 6)
+
+-- call fns
+assert(product1(intPair) == 42)
+assert(product2(intPair) == 42)
+assert(product3(intPair) == 42)
+
+-- also use the pointer version
+assert(product1(intPairPtr) == 42)
+assert(product2(intPairPtr) == 42)
+assert(product3(intPairPtr) == 42)
+
+-- or the other types
+assert(product1(intPairRef) == 42)
+assert(product2(intPairRef) == 42)
+assert(product3(intPairRef) == 42)
+assert(product1(intPairConstRef) == 42)
+assert(product2(intPairConstRef) == 42)
+assert(product3(intPairConstRef) == 42)
diff --git a/Examples/test-suite/lua/li_std_string_runme.lua b/Examples/test-suite/lua/li_std_string_runme.lua
new file mode 100644
index 0000000..70461f7
--- /dev/null
+++ b/Examples/test-suite/lua/li_std_string_runme.lua
@@ -0,0 +1,113 @@
+require("import") -- the import fn
+import("li_std_string") -- import lib
+
+for k,v in pairs(li_std_string) do _G[k]=v end -- move to global
+
+-- catch "undefined" global variables
+setmetatable(getfenv(),{__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
+
+-- helper to check type
+function is_std_string(s)
+ return type(s)=='userdata' and swig_type(s)=='std::string *'
+end
+
+-- std::string by value is just a Lua string
+s=test_value("foo")
+assert(type(s)=="string" and s=="foo")
+
+-- std::string by const ref is also just a Lua string
+s=test_const_reference("foo")
+assert(type(s)=="string" and s=="foo")
+
+-- std:string* is an object
+obj=test_pointer_out()
+assert(is_std_string(obj) and obj:c_str()=="x") -- check type & value
+
+test_pointer(obj) -- this wants an object
+
+cobj=test_const_pointer_out()
+assert(is_std_string(cobj) and cobj:c_str()=="x") -- check type & value
+
+test_const_pointer(cobj)
+
+-- this shouldnt work, but it does
+-- swig doesnt appear to diff between const object ptrs & object ptrs very well
+test_pointer(cobj) -- this wants an non const object (give it a const one!)
+
+-- refs are also wrappered as ptrs (unless the correct typemaps are applied)
+robj=test_reference_out()
+assert(is_std_string(robj) and robj:c_str()=="test_reference_out message") -- check type & value
+
+test_reference(robj)
+test_reference(obj) -- object ptr is ok
+test_reference(cobj) -- obj const ptr is also ok
+
+-- throwing string
+ok,ex=pcall(test_throw)
+assert(ok==false and type(ex)=="string") -- failed & threw string
+
+ok,ex=pcall(test_const_reference_throw)
+assert(ok==false and type(ex)=="string") -- failed & threw string
+
+-- const ptrs are now converted to lua strings
+-- they used to be std::string*
+ok,ex=pcall(test_const_pointer_throw)
+assert(ok==false and type(ex)=="string") -- failed & threw object
+
+-- ditto non const ptrs
+ok,ex=pcall(test_pointer_throw)
+assert(ok==false and type(ex)=="string") -- failed & threw object
+
+-- 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")
+
+-- Member variables
+myStructure = Structure()
+assert(myStructure.MemberString2 == "member string 2")
+myStructure.MemberString2 = s
+assert (myStructure.MemberString2 == s)
+assert (myStructure.ConstMemberString == "const member string")
+
+assert (li_std_string.Structure_StaticMemberString2 == "static member string 2")
+li_std_string.Structure_StaticMemberString2 = s
+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 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
+assert(type(struc.MemberString2)=="string") -- typemaps make this a string
+assert(type(struc.ConstMemberString)=="string")
+
+-- for static types: they are really variables,
+-- so we must still use the module name
+
+-- check static type
+assert(type(li_std_string.Structure_StaticMemberString2)=="string")
+assert(type(li_std_string.Structure_ConstStaticMemberString)=="string")
+
+-- try setting (should fail with error)
+--li_std_string.Structure_StaticMemberString2='e'
+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())]]
+
+-- check static type again
+assert(type(li_std_string.Structure_StaticMemberString)=="string")
+assert(type(li_std_string.Structure_StaticMemberString2)=="string")
+assert(type(li_std_string.Structure_ConstStaticMemberString)=="string")
diff --git a/Examples/test-suite/lua/li_std_vector_runme.lua b/Examples/test-suite/lua/li_std_vector_runme.lua
new file mode 100644
index 0000000..81994b9
--- /dev/null
+++ b/Examples/test-suite/lua/li_std_vector_runme.lua
@@ -0,0 +1,66 @@
+require("import") -- the import fn
+import("li_std_vector") -- import code
+
+for k,v in pairs(li_std_vector) do _G[k]=v end -- move to global
+
+iv = IntVector(4)
+for i=0,3 do
+ iv[i] = i
+end
+
+for i=0,3 do assert(iv[i]==i) end
+
+x = average(iv)
+
+function near(x,y) return math.abs(x-y)<0.001 end
+
+assert(near(x,1.5))
+
+rv = RealVector()
+rv:push_back(10)
+rv:push_back(10.5)
+rv:push_back(11)
+rv:push_back(11.5)
+
+a=half(rv)
+for i=0,rv:size()-1 do
+ assert(near(a[i],rv[i]/2))
+end
+
+dv = DoubleVector(10)
+for i=0,9 do dv[i] = i/2.0 end
+
+halve_in_place(dv)
+
+for i=0,9 do
+ assert(near(dv[i],i/4))
+end
+
+sv=StructVector(4)
+
+for i=0,3 do
+ sv[i]=Struct(i)
+end
+
+for i=0,3 do
+ assert( swig_type(sv[i]) =='Struct *' and sv[i].num==i)
+end
+
+-- range checking
+idx=0
+function test_set() iv[idx]=0 end
+function test_get() iv[idx]=0 end
+
+idx=0 --ok
+assert(pcall(test_get)==true)
+assert(pcall(test_set)==true)
+idx=-1 --should error
+assert(pcall(test_get)==false)
+assert(pcall(test_set)==false)
+idx=3 --ok
+assert(pcall(test_get)==true)
+assert(pcall(test_set)==true)
+idx=4 --should error
+assert(pcall(test_get)==false)
+assert(pcall(test_set)==false)
+
diff --git a/Examples/test-suite/lua/li_typemaps_runme.lua b/Examples/test-suite/lua/li_typemaps_runme.lua
new file mode 100644
index 0000000..77aeb54
--- /dev/null
+++ b/Examples/test-suite/lua/li_typemaps_runme.lua
@@ -0,0 +1,40 @@
+require("import") -- the import fn
+import("li_typemaps") -- import code
+
+-- catch "undefined" global variables
+setmetatable(getfenv(),{__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
+
+-- Check double INPUT typemaps
+assert(li_typemaps.in_double(22.22) == 22.22)
+assert(li_typemaps.inr_double(22.22) == 22.22)
+
+-- Check double OUTPUT typemaps
+assert(li_typemaps.out_double(22.22) == 22.22)
+assert(li_typemaps.outr_double(22.22) == 22.22)
+
+-- Check double INOUT typemaps
+assert(li_typemaps.inout_double(22.22) == 22.22)
+assert(li_typemaps.inoutr_double(22.22) == 22.22)
+
+-- check long long
+assert(li_typemaps.in_ulonglong(20)==20)
+assert(li_typemaps.inr_ulonglong(20)==20)
+assert(li_typemaps.out_ulonglong(20)==20)
+assert(li_typemaps.outr_ulonglong(20)==20)
+assert(li_typemaps.inout_ulonglong(20)==20)
+assert(li_typemaps.inoutr_ulonglong(20)==20)
+
+-- check bools
+assert(li_typemaps.in_bool(true)==true)
+assert(li_typemaps.inr_bool(false)==false)
+assert(li_typemaps.out_bool(true)==true)
+assert(li_typemaps.outr_bool(false)==false)
+assert(li_typemaps.inout_bool(true)==true)
+assert(li_typemaps.inoutr_bool(false)==false)
+
+-- the others
+a,b=li_typemaps.inoutr_int2(1,2)
+assert(a==1 and b==2)
+
+f,i=li_typemaps.out_foo(10)
+assert(f.a==10 and i==20)
diff --git a/Examples/test-suite/lua/member_pointer_runme.lua b/Examples/test-suite/lua/member_pointer_runme.lua
new file mode 100644
index 0000000..8dddab2
--- /dev/null
+++ b/Examples/test-suite/lua/member_pointer_runme.lua
@@ -0,0 +1,43 @@
+--Example using pointers to member functions
+
+require("import") -- the import fn
+import("member_pointer") -- import code
+
+for k,v in pairs(member_pointer) do _G[k]=v end
+
+function check(what, expected, actual)
+ assert(expected == actual,"Failed: "..what.." Expected: "..expected.." Actual: "..actual)
+end
+
+-- Get the pointers
+area_pt = areapt()
+perim_pt = perimeterpt()
+
+-- Create some objects
+s = Square(10)
+
+-- Do some calculations
+check ("Square area ", 100.0, do_op(s,area_pt))
+check ("Square perim", 40.0, do_op(s,perim_pt))
+
+-- Try the variables
+-- these have to still be part of the 'member_pointer' table
+memberPtr = member_pointer.areavar
+memberPtr = member_pointer.perimetervar
+
+check ("Square area ", 100.0, do_op(s,member_pointer.areavar))
+check ("Square perim", 40.0, do_op(s,member_pointer.perimetervar))
+
+-- Modify one of the variables
+member_pointer.areavar = perim_pt
+
+check ("Square perimeter", 40.0, do_op(s,member_pointer.areavar))
+
+-- Try the constants
+memberPtr = AREAPT
+memberPtr = PERIMPT
+memberPtr = NULLPT
+
+check ("Square area ", 100.0, do_op(s,AREAPT))
+check ("Square perim", 40.0, do_op(s,PERIMPT))
+
diff --git a/Examples/test-suite/lua/multi_import_runme.lua b/Examples/test-suite/lua/multi_import_runme.lua
new file mode 100644
index 0000000..5d4c136
--- /dev/null
+++ b/Examples/test-suite/lua/multi_import_runme.lua
@@ -0,0 +1,16 @@
+require("import") -- the import fn
+-- note: need to import the base class module before the derived class
+-- this is because if the derived class is imported first it doesn't get the base class methods
+import("multi_import_b") -- import code
+import("multi_import_a") -- import code
+
+x = multi_import_b.XXX()
+assert(x:testx() == 0)
+
+y = multi_import_b.YYY()
+assert(y:testx() == 0)
+assert(y:testy() == 1)
+
+z = multi_import_a.ZZZ()
+assert(z:testx() == 0)
+assert(z:testz() == 2)
diff --git a/Examples/test-suite/lua/newobject1_runme.lua b/Examples/test-suite/lua/newobject1_runme.lua
new file mode 100644
index 0000000..5de8276
--- /dev/null
+++ b/Examples/test-suite/lua/newobject1_runme.lua
@@ -0,0 +1,16 @@
+require("import") -- the import fn
+import("newobject1") -- import code
+
+foo1 = newobject1.Foo_makeFoo() -- lua doesnt yet support static fns properly
+assert(newobject1.Foo_fooCount() == 1) -- lua doesnt yet support static fns properly
+
+foo2 = foo1:makeMore()
+assert(newobject1.Foo_fooCount() == 2)
+
+foo1 = nil
+collectgarbage()
+assert(newobject1.Foo_fooCount() == 1)
+
+foo2 = nil
+collectgarbage()
+assert(newobject1.Foo_fooCount() == 0)
diff --git a/Examples/test-suite/lua/newobject2_runme.lua b/Examples/test-suite/lua/newobject2_runme.lua
new file mode 100644
index 0000000..cf6c87a
--- /dev/null
+++ b/Examples/test-suite/lua/newobject2_runme.lua
@@ -0,0 +1,16 @@
+require("import") -- the import fn
+import("newobject2",true) -- import code
+
+foo1 = newobject2.makeFoo() -- lua doesnt yet support static fns properly
+assert(newobject2.fooCount() == 1) -- lua doesnt yet support static fns properly
+
+foo2 = newobject2.makeFoo()
+assert(newobject2.fooCount() == 2)
+
+foo1 = nil
+collectgarbage()
+assert(newobject2.fooCount() == 1)
+
+foo2 = nil
+collectgarbage()
+assert(newobject2.fooCount() == 0)
diff --git a/Examples/test-suite/lua/operator_overload_runme.lua b/Examples/test-suite/lua/operator_overload_runme.lua
new file mode 100644
index 0000000..1610c17
--- /dev/null
+++ b/Examples/test-suite/lua/operator_overload_runme.lua
@@ -0,0 +1,157 @@
+-- demo of lua swig capacilities (operator overloading)
+require("import") -- the import fn
+import("operator_overload") -- import lib
+
+for k,v in pairs(operator_overload) do _G[k]=v end -- move to global
+
+-- first check all the operators are implemented correctly from pure C++ code
+Op_sanity_check()
+
+-- catching undefined variables
+setmetatable(getfenv(),{__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
+
+-- test routine:
+a=Op()
+b=Op(5)
+c=Op(b) -- copy construct
+d=Op(2)
+dd=d; -- assignment operator
+
+-- test equality
+assert(a~=b)
+assert(b==c)
+assert(a~=d)
+assert(d==dd)
+
+-- test <
+assert(a<b)
+assert(a<=b)
+assert(b<=c)
+assert(b>=c)
+assert(b>d)
+assert(b>=d)
+
+-- lua does not support += operators: skiping
+
+-- test +
+f=Op(1)
+g=Op(1)
+assert(f+g==Op(2))
+assert(f-g==Op(0))
+assert(f*g==Op(1))
+assert(f/g==Op(1))
+--assert(f%g==Op(0)) -- lua does not support %
+
+-- test unary operators
+--assert((not a)==true) -- lua does not allow overloading for not operator
+--assert((not b)==false) -- lua does not allow overloading for not operator
+
+--lua 5.0.2 defines that unary - is __unm(self,nil)
+--lua 5.1.2 defines that unary - is __unm(self,self)
+--C++ expectes unary - as operator-()
+--however the latest version of SWIG strictly checks the number of args
+--and will complain if too many args are provided
+--therefore disabling these tests for now
+-- (solution will to be not to check args for this test case)
+assert(-a==a)
+assert(-b==Op(-5))
+
+-- test []
+h=Op(3)
+assert(h[0]==3)
+assert(h[1]==0)
+h[0]=2 -- set
+assert(h[0]==2)
+h[1]=2 -- ignored
+assert(h[0]==2)
+assert(h[1]==0)
+
+-- test ()
+i=Op(3)
+assert(i()==3)
+assert(i(1)==4)
+assert(i(1,2)==6)
+
+-- plus add some code to check the __str__ fn
+assert(tostring(Op(1))=="Op(1)")
+assert(tostring(Op(-3))=="Op(-3)")
+
+--[[
+/* Sample test code in C++
+
+#include <assert.h>
+#include <stdio.h>
+
+int main(int argc,char** argv)
+{
+ // test routine:
+ Op a;
+ Op b=5;
+ Op c=b; // copy construct
+ Op d=2;
+
+ // test equality
+ assert(a!=b);
+ assert(b==c);
+ assert(a!=d);
+
+ // test <
+ assert(a<b);
+ assert(a<=b);
+ assert(b<=c);
+ assert(b>=c);
+ assert(b>d);
+ assert(b>=d);
+
+ // test +=
+ Op e=3;
+ e+=d;
+ assert(e==b);
+ e-=c;
+ assert(e==a);
+ e=Op(1);
+ e*=b;
+ assert(e==c);
+ e/=d;
+ assert(e==d);
+ e%=c;
+ assert(e==d);
+
+ // test +
+ Op f(1),g(1);
+ assert(f+g==Op(2));
+ assert(f-g==Op(0));
+ assert(f*g==Op(1));
+ assert(f/g==Op(1));
+ assert(f%g==Op(0));
+
+ // test unary operators
+ assert(!a==true);
+ assert(!b==false);
+ assert(-a==a);
+ assert(-b==Op(-5));
+
+ // test []
+ Op h=3;
+ assert(h[0]==3);
+ assert(h[1]==0);
+ h[0]=2; // set
+ assert(h[0]==2);
+ h[1]=2; // ignored
+ assert(h[0]==2);
+ assert(h[1]==0);
+
+ // test ()
+ Op i=3;
+ assert(i()==3);
+ assert(i(1)==4);
+ assert(i(1,2)==6);
+
+ // plus add some code to check the __str__ fn
+ //assert(str(Op(1))=="Op(1)");
+ //assert(str(Op(-3))=="Op(-3)");
+
+ printf("ok\n");
+}
+*/
+]]
diff --git a/Examples/test-suite/lua/overload_simple_runme.lua b/Examples/test-suite/lua/overload_simple_runme.lua
new file mode 100644
index 0000000..97b1876
--- /dev/null
+++ b/Examples/test-suite/lua/overload_simple_runme.lua
@@ -0,0 +1,55 @@
+require("import") -- the import fn
+import("overload_simple") -- import code
+for k,v in pairs(overload_simple) do _G[k]=v end -- move to global
+
+-- lua has only one numeric type, foo(int) and foo(double) are the same
+-- whichever one was wrapper first will be used
+
+assert(foo(3)=="foo:int" or foo(3)=="foo:double") -- could be either
+assert(foo("hello")=="foo:char *")
+
+f=Foo()
+b=Bar()
+
+assert(foo(f)=="foo:Foo *")
+assert(foo(b)=="foo:Bar *")
+
+v = malloc_void(32)
+
+assert(foo(v) == "foo:void *")
+
+s = Spam()
+
+assert(s:foo(3) == "foo:int" or s:foo(3.0) == "foo:double") -- could be either
+assert(s:foo("hello") == "foo:char *")
+assert(s:foo(f) == "foo:Foo *")
+assert(s:foo(b) == "foo:Bar *")
+assert(s:foo(v) == "foo:void *")
+
+assert(Spam_bar(3) == "bar:int" or Spam_bar(3.0) == "bar:double")
+assert(Spam_bar("hello") == "bar:char *")
+assert(Spam_bar(f) == "bar:Foo *")
+assert(Spam_bar(b) == "bar:Bar *")
+assert(Spam_bar(v) == "bar:void *")
+
+-- Test constructors
+
+s = Spam()
+assert(s.type == "none")
+
+s = Spam(3)
+assert(s.type == "int" or s.type == "double")
+
+s = Spam("hello")
+assert(s.type == "char *")
+
+s = Spam(f)
+assert(s.type == "Foo *")
+
+s = Spam(b)
+assert(s.type == "Bar *")
+
+s = Spam(v)
+assert(s.type == "void *")
+
+free_void(v)
diff --git a/Examples/test-suite/lua/overload_template_fast_runme.lua b/Examples/test-suite/lua/overload_template_fast_runme.lua
new file mode 100644
index 0000000..6663cb0
--- /dev/null
+++ b/Examples/test-suite/lua/overload_template_fast_runme.lua
@@ -0,0 +1,81 @@
+require("import") -- the import fn
+import("overload_template_fast") -- import code
+for k,v in pairs(overload_template_fast) do _G[k]=v end -- move to global
+
+-- lua has only one numeric type, so maximum(int,int) and maximum(double,double) are the same
+-- whichever one was wrapper first will be used (which is int)
+
+f = foo()
+
+a = maximum(3,4)
+
+-- mix 1
+assert(mix1("hi") == 101)
+assert(mix1(1.0, 1.0) == 102)
+assert(mix1(1.0) == 103)
+
+-- mix 2
+assert(mix2("hi") == 101)
+assert(mix2(1.0, 1.0) == 102)
+assert(mix2(1.0) == 103)
+
+-- mix 3
+assert(mix3("hi") == 101)
+assert(mix3(1.0, 1.0) == 102)
+assert(mix3(1.0) == 103)
+
+-- Combination 1
+assert(overtparams1(100) == 10)
+assert(overtparams1(100.0, 100) == 20)
+
+-- Combination 2
+assert(overtparams2(100.0, 100) == 40)
+
+-- Combination 3
+assert(overloaded() == 60)
+assert(overloaded(100.0, 100) == 70)
+
+-- Combination 4
+assert(overloadedagain("hello") == 80)
+assert(overloadedagain() == 90)
+
+-- specializations
+assert(specialization(10) == 202 or specialization(10.0) == 203) -- only one works
+assert(specialization(10, 10) == 204 or specialization(10.0, 10.0) == 205) -- ditto
+assert(specialization("hi", "hi") == 201)
+
+-- simple specialization
+xyz()
+xyz_int()
+xyz_double()
+
+-- a bit of everything
+assert(overload("hi") == 0)
+assert(overload(1) == 10)
+assert(overload(1, 1) == 20)
+assert(overload(1, "hello") == 30)
+
+k = Klass()
+assert(overload(k) == 10)
+assert(overload(k, k) == 20)
+assert(overload(k, "hello") == 30)
+-- this one is incorrect: it mactches overload(10.0, "hi") with int overload(T t, const char *c)
+--print(overload(10.0, "hi"))
+--assert(overload(10.0, "hi") == 40)
+assert(overload() == 50)
+
+-- everything put in a namespace
+assert(nsoverload("hi") == 1000,"nsoverload()")
+assert(nsoverload(1) == 1010,"nsoverload(int t)")
+assert(nsoverload(1, 1) == 1020,"nsoverload(int t, const int &)")
+assert(nsoverload(1, "hello") == 1030,"nsoverload(int t, const char *)")
+assert(nsoverload(k) == 1010,"nsoverload(Klass t)")
+assert(nsoverload(k, k) == 1020,"nsoverload(Klass t, const Klass &)")
+assert(nsoverload(k, "hello") == 1030,"nsoverload(Klass t, const char *)")
+-- again this one fails
+--assert(nsoverload(10.0, "hi") == 1040,"nsoverload(double t, const char *)")
+assert(nsoverload() == 1050,"nsoverload(const char *)")
+
+A_foo(1)
+b = B()
+b:foo(1)
diff --git a/Examples/test-suite/lua/overload_template_runme.lua b/Examples/test-suite/lua/overload_template_runme.lua
new file mode 100644
index 0000000..19cc7e9
--- /dev/null
+++ b/Examples/test-suite/lua/overload_template_runme.lua
@@ -0,0 +1,81 @@
+require("import") -- the import fn
+import("overload_template") -- import code
+for k,v in pairs(overload_template) do _G[k]=v end -- move to global
+
+-- lua has only one numeric type, so maximum(int,int) and maximum(double,double) are the same
+-- whichever one was wrapper first will be used (which is int)
+
+f = foo()
+
+a = maximum(3,4)
+
+-- mix 1
+assert(mix1("hi") == 101)
+assert(mix1(1.0, 1.0) == 102)
+assert(mix1(1.0) == 103)
+
+-- mix 2
+assert(mix2("hi") == 101)
+assert(mix2(1.0, 1.0) == 102)
+assert(mix2(1.0) == 103)
+
+-- mix 3
+assert(mix3("hi") == 101)
+assert(mix3(1.0, 1.0) == 102)
+assert(mix3(1.0) == 103)
+
+-- Combination 1
+assert(overtparams1(100) == 10)
+assert(overtparams1(100.0, 100) == 20)
+
+-- Combination 2
+assert(overtparams2(100.0, 100) == 40)
+
+-- Combination 3
+assert(overloaded() == 60)
+assert(overloaded(100.0, 100) == 70)
+
+-- Combination 4
+assert(overloadedagain("hello") == 80)
+assert(overloadedagain() == 90)
+
+-- specializations
+assert(specialization(10) == 202 or specialization(10.0) == 203) -- only one works
+assert(specialization(10, 10) == 204 or specialization(10.0, 10.0) == 205) -- ditto
+assert(specialization("hi", "hi") == 201)
+
+-- simple specialization
+xyz()
+xyz_int()
+xyz_double()
+
+-- a bit of everything
+assert(overload("hi") == 0)
+assert(overload(1) == 10)
+assert(overload(1, 1) == 20)
+assert(overload(1, "hello") == 30)
+
+k = Klass()
+assert(overload(k) == 10)
+assert(overload(k, k) == 20)
+assert(overload(k, "hello") == 30)
+-- this one is incorrect: it mactches overload(10.0, "hi") with int overload(T t, const char *c)
+--print(overload(10.0, "hi"))
+--assert(overload(10.0, "hi") == 40)
+assert(overload() == 50)
+
+-- everything put in a namespace
+assert(nsoverload("hi") == 1000,"nsoverload()")
+assert(nsoverload(1) == 1010,"nsoverload(int t)")
+assert(nsoverload(1, 1) == 1020,"nsoverload(int t, const int &)")
+assert(nsoverload(1, "hello") == 1030,"nsoverload(int t, const char *)")
+assert(nsoverload(k) == 1010,"nsoverload(Klass t)")
+assert(nsoverload(k, k) == 1020,"nsoverload(Klass t, const Klass &)")
+assert(nsoverload(k, "hello") == 1030,"nsoverload(Klass t, const char *)")
+-- again this one fails
+--assert(nsoverload(10.0, "hi") == 1040,"nsoverload(double t, const char *)")
+assert(nsoverload() == 1050,"nsoverload(const char *)")
+
+A_foo(1)
+b = B()
+b:foo(1)
diff --git a/Examples/test-suite/lua/pointer_reference_runme.lua b/Examples/test-suite/lua/pointer_reference_runme.lua
new file mode 100644
index 0000000..959d5a2
--- /dev/null
+++ b/Examples/test-suite/lua/pointer_reference_runme.lua
@@ -0,0 +1,11 @@
+require("import") -- the import fn
+import("pointer_reference",true) -- import code
+
+
+s=pointer_reference.get()
+assert(s.value == 10)
+
+ss = pointer_reference.Struct(20);
+pointer_reference.set(ss);
+assert(pointer_reference.Struct_instance.value == 20)
+
diff --git a/Examples/test-suite/lua/primitive_ref_runme.lua b/Examples/test-suite/lua/primitive_ref_runme.lua
new file mode 100644
index 0000000..d3da5dc
--- /dev/null
+++ b/Examples/test-suite/lua/primitive_ref_runme.lua
@@ -0,0 +1,32 @@
+require("import") -- the import fn
+import("primitive_ref") -- import code
+pr=primitive_ref --alias
+
+assert(pr.ref_int(3)==3)
+
+assert(pr.ref_uint(3) == 3)
+
+assert(pr.ref_short(3) == 3)
+
+assert(pr.ref_ushort(3) == 3)
+
+assert(pr.ref_long(3) == 3)
+
+assert(pr.ref_ulong(3) == 3)
+
+assert(pr.ref_schar(3) == 3)
+
+assert(pr.ref_uchar(3) == 3)
+
+assert(pr.ref_float(3.5) == 3.5)
+
+assert(pr.ref_double(3.5) == 3.5)
+
+assert(pr.ref_bool(true) == true)
+
+assert(pr.ref_char('x') == 'x')
+
+assert(pr.ref_over(0) == 0)
+
+a=pr.A(12)
+assert(pr.ref_over(a)==12)
diff --git a/Examples/test-suite/lua/ret_by_value_runme.lua b/Examples/test-suite/lua/ret_by_value_runme.lua
new file mode 100644
index 0000000..f1f5c6c
--- /dev/null
+++ b/Examples/test-suite/lua/ret_by_value_runme.lua
@@ -0,0 +1,6 @@
+require("import") -- the import fn
+import("ret_by_value") -- import code
+
+a = ret_by_value.get_test()
+assert(a.myInt == 100)
+assert(a.myShort == 200)
diff --git a/Examples/test-suite/lua/sizet_runme.lua b/Examples/test-suite/lua/sizet_runme.lua
new file mode 100644
index 0000000..fbaea6a
--- /dev/null
+++ b/Examples/test-suite/lua/sizet_runme.lua
@@ -0,0 +1,9 @@
+require("import") -- the import fn
+import("sizet") -- import code
+
+s = 2000
+s = sizet.test1(s+1)
+s = sizet.test2(s+1)
+s = sizet.test3(s+1)
+s = sizet.test4(s+1)
+assert(s == 2004)
diff --git a/Examples/test-suite/lua/smart_pointer_overload_runme.lua b/Examples/test-suite/lua/smart_pointer_overload_runme.lua
new file mode 100644
index 0000000..b83bede
--- /dev/null
+++ b/Examples/test-suite/lua/smart_pointer_overload_runme.lua
@@ -0,0 +1,14 @@
+require("import") -- the import fn
+import("smart_pointer_overload") -- import code
+for k,v in pairs(smart_pointer_overload) do _G[k]=v end -- move to global
+
+f = Foo()
+b = Bar(f)
+
+assert(f:test(3) == 1)
+--assert(f:test(3.5) == 2) -- won't work due to being unable to overloads
+assert(f:test("hello") == 3)
+
+assert(b:test(3) == 1)
+--assert(b:test(3.5) == 2) -- won't work due to being unable to overloads
+assert(b:test("hello") == 3)
diff --git a/Examples/test-suite/lua/template_default_arg_runme.lua b/Examples/test-suite/lua/template_default_arg_runme.lua
new file mode 100644
index 0000000..ebb22ed
--- /dev/null
+++ b/Examples/test-suite/lua/template_default_arg_runme.lua
@@ -0,0 +1,63 @@
+require("import") -- the import fn
+import("template_default_arg") -- import code
+--for k,v in pairs(template_default_arg) do _G[k]=v end -- move to global
+
+helloInt = template_default_arg.Hello_int()
+helloInt:foo(template_default_arg.Hello_int_hi)
+
+x = template_default_arg.X_int()
+assert(x:meth(20.0, 200) == 200,"X_int test 1 failed")
+assert(x:meth(20) == 20,"X_int test 2 failed")
+assert(x:meth() == 0,"X_int test 3 failed")
+
+y = template_default_arg.Y_unsigned()
+assert(y:meth(20.0, 200) == 200,"Y_unsigned test 1 failed")
+assert(y:meth(20) == 20,"Y_unsigned test 2 failed")
+assert(y:meth() == 0,"Y_unsigned test 3 failed")
+
+x = template_default_arg.X_longlong()
+x = template_default_arg.X_longlong(20.0)
+x = template_default_arg.X_longlong(20.0, 200) -- note: long longs just treated as another number
+
+x = template_default_arg.X_int()
+x = template_default_arg.X_int(20.0)
+x = template_default_arg.X_int(20.0, 200)
+
+x = template_default_arg.X_hello_unsigned()
+x = template_default_arg.X_hello_unsigned(20.0)
+x = template_default_arg.X_hello_unsigned(20.0, template_default_arg.Hello_int())
+
+y = template_default_arg.Y_hello_unsigned()
+y:meth(20.0, template_default_arg.Hello_int())
+y:meth(template_default_arg.Hello_int())
+y:meth()
+
+fz = template_default_arg.Foo_Z_8()
+x = template_default_arg.X_Foo_Z_8()
+fzc = x:meth(fz)
+
+-- Templated functions
+
+-- plain function: int ott(Foo<int>)
+assert(template_default_arg.ott(template_default_arg.Foo_int()) == 30,"ott test 1 failed")
+
+-- %template(ott) ott<int, int>
+assert(template_default_arg.ott() == 10,"ott test 2 failed")
+assert(template_default_arg.ott(1) == 10,"ott test 3 failed")
+assert(template_default_arg.ott(1, 1) == 10,"ott test 4 failed")
+
+assert(template_default_arg.ott("hi") == 20,"ott test 5 failed")
+assert(template_default_arg.ott("hi", 1) == 20,"ott test 6 failed")
+assert(template_default_arg.ott("hi", 1, 1) == 20,"ott test 7 failed")
+
+-- %template(ott) ott<const char *>
+assert(template_default_arg.ottstring(template_default_arg.Hello_int(), "hi") == 40,"ott test 8 failed")
+assert(template_default_arg.ottstring(template_default_arg.Hello_int()) == 40,"ott test 9 failed")
+
+-- %template(ott) ott<int>
+assert(template_default_arg.ottint(template_default_arg.Hello_int(), 1) == 50,"ott test 10 failed")
+assert(template_default_arg.ottint(template_default_arg.Hello_int()) == 50,"ott test 11 failed")
+
+-- %template(ott) ott<double>
+assert(template_default_arg.ott(template_default_arg.Hello_int(), 1.0) == 60,"ott test 12 failed")
+assert(template_default_arg.ott(template_default_arg.Hello_int()) == 60,"ott test 13 failed")
diff --git a/Examples/test-suite/lua/voidtest_runme.lua b/Examples/test-suite/lua/voidtest_runme.lua
new file mode 100644
index 0000000..e185dbd
--- /dev/null
+++ b/Examples/test-suite/lua/voidtest_runme.lua
@@ -0,0 +1,37 @@
+-- demo of lua swig
+require("import") -- the import fn
+import("voidtest") -- import lib
+
+-- test calling functions
+voidtest.globalfunc()
+f = voidtest.Foo()
+f:memberfunc() -- member fns must have : not a .
+
+voidtest.Foo_staticmemberfunc() -- static member fns are still a little messy
+
+v1 = voidtest.vfunc1(f)
+v2 = voidtest.vfunc2(f)
+
+assert(swig_equals(v1,v2)) -- a raw equals will not work, we look at the raw pointers
+
+v3 = voidtest.vfunc3(v1)
+assert(swig_equals(v3,f))
+
+v4 = voidtest.vfunc1(f)
+assert(swig_equals(v4,v1))
+
+v3:memberfunc()
+
+-- also testing nil's support
+-- nil, are acceptable anywhere a pointer is
+n1 = voidtest.vfunc1(nil)
+n2 = voidtest.vfunc2(nil)
+
+assert(n1==nil)
+assert(n2==nil)
+
+n3 = voidtest.vfunc3(n1)
+n4 = voidtest.vfunc1(nil)
+
+assert(n3==nil)
+assert(n4==nil)