4 if string.sub(_VERSION,1,7)=='Lua 5.0' then
5 -- lua5.0 doesnt have a nice way to do this
6 lib=loadlib('example.dll','luaopen_example') or loadlib('example.so','luaopen_example')
13 print("ICONST = "..example.ICONST.." (should be 42)")
14 print("FCONST = "..example.FCONST.." (should be 2.1828)")
15 print("CCONST = "..example.CCONST.." (should be 'x')")
16 print("CCONST2 = "..example.CCONST2.." (this should be on a new line)")
17 print("SCONST = "..example.SCONST.." (should be 'Hello World')")
18 print("SCONST2 = "..example.SCONST2.." (should be '\"Hello World\"')")
19 print("EXPR = "..example.EXPR.." (should be 48.5484)")
20 print("iconst = "..example.iconst.." (should be 37)")
21 print("fconst = "..example.fconst.." (should be 3.14)")
23 -- helper to check that a fn failed
24 function checkfail(fn)
25 if pcall(fn)==true then
26 print("that shouldn't happen, it worked")
28 print("function failed as expected")
33 -- example.EXTERN is a nil value, so concatentatin will make it fail
34 checkfail(function() print("EXTERN = "..example.EXTERN) end)
35 checkfail(function() print("FOO = "..example.FOO) end)