Bugfixes. CMD args handling. Code cleanup
This commit is contained in:
parent
7e052c1873
commit
da0510376c
5 changed files with 220 additions and 118 deletions
|
|
@ -1,8 +1,6 @@
|
|||
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
|
||||
lc = li_carrays
|
||||
|
||||
-- catch "undefined" global variables
|
||||
local env = _ENV -- Lua 5.2
|
||||
|
|
@ -10,22 +8,22 @@ if not env then env = getfenv () end -- Lua 5.1
|
|||
setmetatable(env, {__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)
|
||||
ary = lc.new_intArray(2)
|
||||
lc.intArray_setitem(ary, 0, 0)
|
||||
lc.intArray_setitem(ary, 1, 1)
|
||||
assert(lc.intArray_getitem(ary, 0)==0)
|
||||
assert(lc.intArray_getitem(ary, 1)==1)
|
||||
lc.delete_intArray(ary)
|
||||
|
||||
-- Testing for %array_class(double, doubleArray)
|
||||
d = doubleArray(10)
|
||||
d = lc.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
|
||||
d2 = lc.doubleArray_frompointer(ptr) -- and back to array
|
||||
assert(d2[5] + d2[0] == 17)
|
||||
--print(d2[5] + d2[0])
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue