Compare commits
No commits in common. '6f5e8386ebd5d8084ea847000cec91af33896b7e' and 'd2a1a8ebe5eece347473af308470da9303b076f6' have entirely different histories.
6f5e8386eb
...
d2a1a8ebe5
@ -1,59 +0,0 @@
|
|||||||
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