mirror of
https://github.com/joe7575/techpack.git
synced 2024-11-22 07:13:48 +01:00
not needed
This commit is contained in:
parent
b2c050dc2a
commit
e011819891
@ -1,50 +0,0 @@
|
||||
core = {}
|
||||
|
||||
function core.global_exists(name)
|
||||
return false
|
||||
end
|
||||
|
||||
dofile('/home/joachim/minetest/builtin/common/vector.lua')
|
||||
dofile('/home/joachim/minetest/builtin/common/misc_helpers.lua')
|
||||
|
||||
safer_lua = {}
|
||||
dofile('/home/joachim/minetest/mods/techpack/safer_lua/store.lua')
|
||||
dofile('/home/joachim/minetest/mods/techpack/safer_lua/scanner.lua')
|
||||
dofile('/home/joachim/minetest/mods/techpack/safer_lua/environ.lua')
|
||||
|
||||
--local Cache = {}
|
||||
--local key = minetest.pos_to_hash(pos)
|
||||
--code = Cache[key]
|
||||
|
||||
local function foo(self, val)
|
||||
--_G = self._G
|
||||
print("Hallo", val)
|
||||
end
|
||||
|
||||
local function error(pos, s)
|
||||
print("[Test] "..s)
|
||||
end
|
||||
|
||||
local init = "init = 5"
|
||||
local loop = [[
|
||||
$foo("hallo")
|
||||
$foo("hallo")
|
||||
$foo(math.floor(5.5))
|
||||
$foo("Joe")
|
||||
a = Store()
|
||||
a.set("a", 123)
|
||||
$foo(a.get("a"))
|
||||
$foo(ticks)
|
||||
if ticks == 10 then $foo("Fehler")
|
||||
|
||||
]]
|
||||
|
||||
local env = {foo = foo}
|
||||
|
||||
|
||||
local code = safer_lua.init(0, init, loop, env, error)
|
||||
if code then
|
||||
print(safer_lua.run_loop(0, 0, code, error))
|
||||
safer_lua.run_loop(0, 1, code, error)
|
||||
safer_lua.run_loop(0, 2, code, error)
|
||||
end
|
@ -1,28 +0,0 @@
|
||||
core = {}
|
||||
|
||||
function core.global_exists(name)
|
||||
return false
|
||||
end
|
||||
|
||||
dofile('/home/joachim/minetest/builtin/common/vector.lua')
|
||||
dofile('/home/joachim/minetest/builtin/common/misc_helpers.lua')
|
||||
dofile('/home/joachim/minetest/mods/techpack/safer_lua/scanner.lua')
|
||||
|
||||
code = [[
|
||||
-- GOOD
|
||||
a = 1
|
||||
a = a + 1
|
||||
print(a)
|
||||
foo(a)
|
||||
|
||||
-- BAD
|
||||
_G.print(()
|
||||
t = {}
|
||||
for i = 1,1000 do
|
||||
]]
|
||||
|
||||
local function error(s)
|
||||
print("[Robbi] "..s)
|
||||
end
|
||||
|
||||
safer_lua:check(code, "Code", error)
|
@ -1,57 +0,0 @@
|
||||
core = {}
|
||||
|
||||
function core.global_exists(name)
|
||||
return false
|
||||
end
|
||||
|
||||
dofile('/home/joachim/minetest/builtin/common/vector.lua')
|
||||
dofile('/home/joachim/minetest/builtin/common/misc_helpers.lua')
|
||||
|
||||
safer_lua = {}
|
||||
safer_lua.MaxTableSize = 1000 -- number of table entries considering string lenghts
|
||||
|
||||
dofile('/home/joachim/minetest/mods/techpack/safer_lua/store.lua')
|
||||
|
||||
|
||||
print("S1")
|
||||
local s1 = safer_lua.Store()
|
||||
assert(s1.size() == 0)
|
||||
|
||||
s1.a = 3
|
||||
s1[1] = 4
|
||||
assert(s1.size() == 0)
|
||||
|
||||
s1.set("b", "Hallo")
|
||||
assert(s1.size() == 5)
|
||||
|
||||
assert(s1.get("b") == "Hallo")
|
||||
assert(s1.size() == 5)
|
||||
|
||||
print("S2")
|
||||
local s2 = safer_lua.Store()
|
||||
assert(s2.size() == 0)
|
||||
s2.set("b", "Joe")
|
||||
assert(s2.size() == 3)
|
||||
|
||||
assert(s2.b == nil)
|
||||
assert(s2.get('b') == "Joe")
|
||||
s2.c = "XXX!"
|
||||
assert(s2.c == nil)
|
||||
|
||||
s1.set("c", s2)
|
||||
print(dump(s1.get("c")))
|
||||
|
||||
print("S3")
|
||||
local s3 = safer_lua.Store(1,2,3,4)
|
||||
assert(s3.size() == 4)
|
||||
print(dump(s3))
|
||||
|
||||
s3.insert(0, 1)
|
||||
s3.insert(5)
|
||||
print(s3.dump())
|
||||
print(s2.dump())
|
||||
|
||||
s2.set("s2", s2)
|
||||
print(s2.dump())
|
||||
|
||||
print(dump(s2))
|
Loading…
Reference in New Issue
Block a user