-
Notifications
You must be signed in to change notification settings - Fork 71
/
Copy pathno_luasocket.lua
44 lines (33 loc) · 964 Bytes
/
no_luasocket.lua
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
-- make sure we are pointing to the local copas first
package.path = string.format("../src/?.lua;%s", package.path)
print([[
Testing to run Copas without LuaSocket, just LuaSystem
=============================================================================
]])
-- patch require to no longer load luasocket
local _require = require
_G.require = function(name)
if name == "socket" then
error("luasocket is not allowed in this test")
end
return _require(name)
end
local copas = require "copas"
local timer = copas.timer
local successes = 0
local t1 -- luacheck: ignore
copas.loop(function()
t1 = timer.new({
delay = 0.1,
recurring = true,
callback = function(timer_obj, params)
successes = successes + 1 -- 6 to come
if successes == 6 then
timer_obj:cancel()
end
end,
})
-- succes count = 6
end)
assert(successes == 6, "number of successes didn't match! got: "..successes)
print("test success!")