summaryrefslogtreecommitdiff
path: root/Examples/test-suite/lua/cpp_namespace_runme.lua
blob: 6f59cb14bf84e56201424651fa2f8bb04206d1f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
require("import")	-- the import fn
import("cpp_namespace")	-- import lib into global
cn=cpp_namespace --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(cn.fact(4) == 24)
assert(cn.Foo == 42)

t1 = cn.Test()
assert(t1:method() == "Test::method")

cn.weird("t1", 4)

assert(cn.do_method(t1) == "Test::method")
assert(cn.do_method2(t1) == "Test::method")

t2 = cn.Test2()
assert(t2:method() == "Test2::method")


assert(cn.foo3(5) == 5)

assert(cn.do_method3(t2, 7) == "Test2::method")