-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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!") |