tests
This commit is contained in:
parent
fd8e77555a
commit
2d239c65ea
49
test.lua
49
test.lua
@ -1,44 +1,17 @@
|
||||
package.path="?.lua;?/init.lua;?.lua;?/?/init.lua;"..package.path
|
||||
local multi,thread = require("multi"):init()
|
||||
|
||||
-- Testing destroying and fixed connections
|
||||
c = multi:newConnection()
|
||||
c1 = c(function()
|
||||
print("called 1")
|
||||
end)
|
||||
c2 = c(function()
|
||||
print("called 2")
|
||||
end)
|
||||
c3 = c(function()
|
||||
print("called 3")
|
||||
end)
|
||||
|
||||
print(c1,c2.Type,c3)
|
||||
c:Fire()
|
||||
c2:Destroy()
|
||||
print(c1,c2.Type,c3)
|
||||
c:Fire()
|
||||
c1:Destroy()
|
||||
print(c1,c2.Type,c3)
|
||||
c:Fire()
|
||||
|
||||
-- Destroying alarms and threads
|
||||
local test = multi:newThread(function()
|
||||
local GLOBAL, THREAD = require("multi.integration.lanesManager"):init()
|
||||
multi:newSystemThread("test",function(msg)
|
||||
print("In thread:", THREAD.getID(), "Msg:", msg)
|
||||
while true do
|
||||
-- Hold forever :D
|
||||
end
|
||||
end,"Passing a message")
|
||||
multi:newThread("localthread",function()
|
||||
print("In local thread :D")
|
||||
while true do
|
||||
thread.sleep(1)
|
||||
print("Hello!")
|
||||
print("...")
|
||||
end
|
||||
end)
|
||||
|
||||
test.OnDeath(function()
|
||||
os.exit() -- This is the last thing called.
|
||||
end)
|
||||
|
||||
local alarm = multi:newAlarm(4):OnRing(function(a)
|
||||
print(a.Type)
|
||||
a:Destroy()
|
||||
print(a.Type)
|
||||
test:Destroy()
|
||||
print("TEST: ",test)
|
||||
end)
|
||||
multi:lightloop()
|
||||
multi:mainloop()
|
||||
Loading…
x
Reference in New Issue
Block a user