Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

More tests

  • Loading branch information...
commit 89bc5576c99a6b41eb52c179c4c8e694f3409128 1 parent b9ba05b
@v-for-vandal v-for-vandal authored wsfulton committed
View
2  Examples/test-suite/keyword_rename.i
@@ -32,8 +32,10 @@ KW(go, defer)
KW(chan, fallthrough)
/* Lua keywords */
+#if defined(SWIGLUA)
KW(end, function)
KW(nil,local)
+#endif
%}
View
11 Examples/test-suite/lua/enum_plus_runme.lua
@@ -0,0 +1,11 @@
+require("import") -- the import fn
+import("enum_plus") -- import lib
+ep=enum_plus
+
+-- catch "undefined" global variables
+local env = _ENV -- Lua 5.2
+if not env then env = getfenv () end -- Lua 5.1
+setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
+
+assert(ep.iFoo_Phoo == 50) -- Old variant of enum bindings
+assert(ep.iFoo.Phoo == 50) -- New variant of enum bindings
View
11 Examples/test-suite/lua/enum_rename_runme.lua
@@ -0,0 +1,11 @@
+require("import") -- the import fn
+import("enum_rename") -- import lib
+er=enum_rename
+
+-- catch "undefined" global variables
+local env = _ENV -- Lua 5.2
+if not env then env = getfenv () end -- Lua 5.1
+setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
+
+assert(er.M_Jan ~= nil)
+assert(er.May ~= nil)
View
12 Examples/test-suite/lua/enum_scope_template_runme.lua
@@ -0,0 +1,12 @@
+require("import") -- the import fn
+import("enum_scope_template") -- import lib
+est=enum_scope_template
+
+-- catch "undefined" global variables
+local env = _ENV -- Lua 5.2
+if not env then env = getfenv () end -- Lua 5.1
+setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
+
+assert(est.TreeInt.Oak ~= nil)
+assert(est.TreeInt_Oak ~= nil)
+assert(est.TreeInt.Cedar ~= nil)
View
16 Examples/test-suite/lua/enum_template_runme.lua
@@ -0,0 +1,16 @@
+require("import") -- the import fn
+import("enum_template") -- import lib
+et=enum_template
+
+-- catch "undefined" global variables
+local env = _ENV -- Lua 5.2
+if not env then env = getfenv () end -- Lua 5.1
+setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
+
+assert(et.eTest0 ~= nil)
+assert(et.eTest1 ~= nil)
+
+et.TakeETest(et.eTest0)
+
+res = et.MakeETest()
+et.TakeETest(res)
View
14 Examples/test-suite/lua/inherit_missing_runme.lua
@@ -0,0 +1,14 @@
+require("import") -- the import fn
+import("inherit_missing") -- import lib
+im=inherit_missing
+
+-- catch "undefined" global variables
+local env = _ENV -- Lua 5.2
+if not env then env = getfenv () end -- Lua 5.1
+setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
+
+bar = im.Bar()
+spam = im.Spam()
+
+assert(im.do_blah(bar) == "Bar::blah")
+assert(im.do_blah(spam) == "Spam::blah")
View
22 Examples/test-suite/lua/nested_workaround_runme.lua
@@ -0,0 +1,22 @@
+require("import") -- the import fn
+import("nested_workaround") -- import lib
+nw=nested_workaround
+
+-- catch "undefined" global variables
+local env = _ENV -- Lua 5.2
+if not env then env = getfenv () end -- Lua 5.1
+setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
+
+i1 = nw.Inner(5)
+assert(i1:getValue() == 5)
+i1:setValue(7)
+assert(i1:getValue() == 7)
+
+o1 = nw.Outer()
+i2 = o1:createInner(9)
+assert(i2:getValue() == 9)
+i2:setValue(11)
+assert(o1:getInnerValue(i2) == 11)
+
+i3 = o1:doubleInnerValue(i2)
+assert(i3:getValue() == 22)
View
26 Examples/test-suite/lua/refcount_runme.lua
@@ -0,0 +1,26 @@
+require("import") -- the import fn
+import("refcount") -- import lib
+r=refcount
+
+-- catch "undefined" global variables
+local env = _ENV -- Lua 5.2
+if not env then env = getfenv () end -- Lua 5.1
+setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
+
+a = r.A()
+assert(a:ref_count() == 1)
+
+b1 = r.B(a)
+assert(a:ref_count() == 2)
+
+b2 = r.B.create(a)
+assert(a:ref_count() == 3)
+
+b3 = b2:cloner()
+assert(a:ref_count() == 4)
+
+rca = b1:get_rca() -- RCPtr<A> is not wrapped
+assert(a:ref_count() == 5)
+
+b4 = r.global_create(a)
+assert(a:ref_count() == 6)
View
37 Examples/test-suite/lua/static_const_member_2_runme.lua
@@ -0,0 +1,37 @@
+require("import") -- the import fn
+import("static_const_member_2") -- import lib
+scm=static_const_member_2
+
+-- catch "undefined" global variables
+local env = _ENV -- Lua 5.2
+if not env then env = getfenv () end -- Lua 5.1
+setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
+
+assert(scm.CavityPackFlags.forward_field == 1)
+assert(scm.CavityPackFlags.backward_field == 2)
+assert(scm.CavityPackFlags.cavity_flags == 3)
+
+assert(scm.CavityPackFlags.flags == 0)
+scm.CavityPackFlags.flags = 91
+assert(scm.CavityPackFlags.flags == 91)
+assert(scm.CavityPackFlags_flags == 91) -- old style bindings
+
+assert(scm.CavityPackFlags.reftest == 42)
+
+assert(scm.Test_int.LeftIndex ~= nil)
+assert(scm.Test_int.current_profile == 4)
+
+assert(scm.Foo.BAR.val == 1)
+assert(scm.Foo.BAZ.val == 2)
+
+assert(scm.Foo_BAR.val == 1)
+assert(scm.Foo_BAZ.val == 2)
+
+scm.Foo.BAR.val = 4
+scm.Foo.BAZ.val = 5
+
+assert(scm.Foo.BAR.val == 4)
+assert(scm.Foo.BAZ.val == 5)
+
+assert(scm.Foo_BAR.val == 4)
+assert(scm.Foo_BAZ.val == 5)
View
17 Examples/test-suite/lua/static_const_member_runme.lua
@@ -0,0 +1,17 @@
+require("import") -- the import fn
+import("static_const_member") -- import lib into global
+scm=static_const_member --alias
+
+-- catching undefined variables
+local env = _ENV -- Lua 5.2
+if not env then env = getfenv () end -- Lua 5.1
+setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
+
+assert(scm.X.PN == 0)
+assert(scm.X.CN == 1)
+assert(scm.X.EN == 2)
+
+-- Old-style bindings
+assert(scm.X_PN == 0)
+assert(scm.X_CN == 1)
+assert(scm.X_EN == 2)
View
20 Examples/test-suite/lua/template_static_runme.lua
@@ -0,0 +1,20 @@
+require("import") -- the import fn
+import("template_static") -- import lib
+ts=template_static
+
+-- catch "undefined" global variables
+local env = _ENV -- Lua 5.2
+if not env then env = getfenv () end -- Lua 5.1
+setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
+
+assert(ts.foo_i.test == 0)
+ts.foo_i.test = 42
+assert(ts.foo_i.test == 42)
+assert(ts.foo_i_test == 42)
+ts.foo_i_test = 57
+assert(ts.foo_i.test == 57)
+assert(ts.foo_i_test == 57)
+assert(ts.foo_d.test == 0)
+
+assert(ts.Foo.bar_double(4) == 1.0)
+assert(ts.Foo_bar_double(4) == 1.0)
View
18 Examples/test-suite/lua/varargs_runme.lua
@@ -0,0 +1,18 @@
+require("import") -- the import fn
+import("varargs") -- import lib
+v=varargs
+
+-- catch "undefined" global variables
+local env = _ENV -- Lua 5.2
+if not env then env = getfenv () end -- Lua 5.1
+setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
+
+assert(v.test("Hello") == "Hello")
+assert(v.test_def("Hello",0) == "Hello")
+
+assert(v.Foo.statictest("Hello") == "Hello")
+assert(v.Foo.statictest("Hello",1) == "Hello")
+
+assert(v.test_plenty("Hello") == "Hello")
+assert(v.test_plenty("Hello",1) == "Hello")
+assert(v.test_plenty("Hello",1,2) == "Hello")
Please sign in to comment.
Something went wrong with that request. Please try again.