From b6dd6f29f65cab54cfbec2ec234c05abd8ab46bd Mon Sep 17 00:00:00 2001 From: ruki Date: Wed, 11 Dec 2019 00:46:15 +0800 Subject: impl scheduler.sleep --- tests/modules/scheduler/test.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/modules/scheduler/test.lua b/tests/modules/scheduler/test.lua index 364b87d2d..3e5cb83b1 100644 --- a/tests/modules/scheduler/test.lua +++ b/tests/modules/scheduler/test.lua @@ -15,16 +15,20 @@ end function test_sleep(t) - --[[ + local count = 0 local task = function (a) local dt = os.mclock() scheduler.sleep(500) dt = os.mclock() - dt t:require(dt > 100 and dt < 1000) + count = count + 1 + if count == 3 then + scheduler.stop() + end end for i = 1, 3 do scheduler.co_start(task) end - scheduler.runloop()]] + scheduler.runloop() end -- cgit v1.3.1