Compare commits
2 Commits
d2a1a8ebe5
...
6f5e8386eb
| Author | SHA1 | Date |
|---|---|---|
|
|
6f5e8386eb | 3 years ago |
|
|
c4e0d9dfe7 | 3 years ago |
@ -0,0 +1,59 @@
|
|||||||
|
local test = require("u-test")
|
||||||
|
|
||||||
|
local serialization = require("serialization")
|
||||||
|
local computer = require("computer")
|
||||||
|
local uuid = require("uuid")
|
||||||
|
|
||||||
|
local computer_uptime_saved
|
||||||
|
function test.os_clock.start_up()
|
||||||
|
computer_uptime_saved = computer.uptime
|
||||||
|
computer.uptime = nil
|
||||||
|
end
|
||||||
|
function test.os_clock.tear_down()
|
||||||
|
computer.uptime = computer_uptime_saved
|
||||||
|
-- Force reload of the module
|
||||||
|
package.loaded.bc = nil
|
||||||
|
local BaseControl = require("bc")
|
||||||
|
end
|
||||||
|
|
||||||
|
function test.os_clock.test_monkeypatched()
|
||||||
|
-- Force reload of the module
|
||||||
|
package.loaded.bc = nil
|
||||||
|
local BaseControl = require("bc")
|
||||||
|
|
||||||
|
-- Test a timeout to prove it works
|
||||||
|
local bc1 = BaseControl:new()
|
||||||
|
test.error_raised(function()
|
||||||
|
bc1:finalize({"to_final1"}, 0.1)
|
||||||
|
end, "timeout")
|
||||||
|
end
|
||||||
|
|
||||||
|
local uuid_next_saved
|
||||||
|
function test.uuid.start_up()
|
||||||
|
uuid_next_saved = uuid.next
|
||||||
|
uuid.next = nil
|
||||||
|
end
|
||||||
|
function test.uuid.tear_down()
|
||||||
|
uuid.next = uuid_next_saved
|
||||||
|
-- Force reload of the module
|
||||||
|
package.loaded.bc = nil
|
||||||
|
local BaseControl = require("bc")
|
||||||
|
end
|
||||||
|
|
||||||
|
function test.uuid.test_monkeypatched()
|
||||||
|
-- Force reload of the module
|
||||||
|
package.loaded.bc = nil
|
||||||
|
local BaseControl = require("bc")
|
||||||
|
|
||||||
|
-- Test a listener as this will use a uuid
|
||||||
|
local bc = BaseControl:new()
|
||||||
|
bc:register("lisuuid1", 1234)
|
||||||
|
bc:finalize()
|
||||||
|
|
||||||
|
local id1 = bc:listen(
|
||||||
|
"lisuuid1", bc.Query.Change, function(new) end)
|
||||||
|
local id2 = bc:listen(
|
||||||
|
"lisuuid1", bc.Query.Change, function(new) end)
|
||||||
|
|
||||||
|
test.not_equal(id1, id2, "uuid collision")
|
||||||
|
end
|
||||||
Loading…
Reference in new issue