diff options
author | 2016-03-04 20:18:47 +0100 | |
---|---|---|
committer | 2016-03-04 20:18:47 +0100 | |
commit | 24276fc7dbf8090f1952cf9ac97cb109a32e3b33 (patch) | |
tree | 974576016c6cae0e3b0bc049b559202f378cfac4 /3rdparty/luv/tests/test-timer.lua | |
parent | 7dd36aaf2f6611ff9b0fcab787d7ea68d30ea7f6 (diff) |
removed Apache 2 licensed library since it is not possible to mix with GPL2 (nw)
Diffstat (limited to '3rdparty/luv/tests/test-timer.lua')
-rw-r--r-- | 3rdparty/luv/tests/test-timer.lua | 87 |
1 files changed, 0 insertions, 87 deletions
diff --git a/3rdparty/luv/tests/test-timer.lua b/3rdparty/luv/tests/test-timer.lua deleted file mode 100644 index f9eb9d89c5f..00000000000 --- a/3rdparty/luv/tests/test-timer.lua +++ /dev/null @@ -1,87 +0,0 @@ -return require('lib/tap')(function (test) - - -- This tests using timers for a simple timeout. - -- It also tests the handle close callback and - test("simple timeout", function (print, p, expect, uv) - local timer = uv.new_timer() - local function onclose() - p("closed", timer) - end - local function ontimeout() - p("timeout", timer) - uv.close(timer, expect(onclose)) - end - uv.timer_start(timer, 10, 0, expect(ontimeout)) - end) - - -- This is like the previous test, but using repeat. - test("simple interval", function (print, p, expect, uv) - local timer = uv.new_timer() - local count = 3 - local onclose = expect(function () - p("closed", timer) - end) - local function oninterval() - p("interval", timer) - count = count - 1 - if count == 0 then - uv.close(timer, onclose) - end - end - uv.timer_start(timer, 10, 10, oninterval) - end) - - -- Test two concurrent timers - -- There is a small race condition, but there are 100ms of wiggle room. - -- 400ms is halfway between 100+200ms and 100+400ms - test("timeout with interval", function (print, p, expect, uv) - local a = uv.new_timer() - local b = uv.new_timer() - uv.timer_start(a, 400, 0, expect(function () - p("timeout", a) - uv.timer_stop(b) - uv.close(a) - uv.close(b) - end)) - uv.timer_start(b, 100, 200, expect(function () - p("interval", b) - end, 2)) - end) - - -- This advanced test uses the rest of the uv_timer_t functions - -- to create an interval that shrinks over time. - test("shrinking interval", function (print, p, expect, uv) - local timer = uv.new_timer() - uv.timer_start(timer, 10, 0, expect(function () - local r = uv.timer_get_repeat(timer) - p("interval", timer, r) - if r == 0 then - uv.timer_set_repeat(timer, 8) - uv.timer_again(timer) - elseif r == 2 then - uv.timer_stop(timer) - uv.close(timer) - else - uv.timer_set_repeat(timer, r / 2) - end - end, 4)) - end) - - test("shrinking interval using methods", function (print, p, expect, uv) - local timer = uv.new_timer() - timer:start(10, 0, expect(function () - local r = timer:get_repeat() - p("interval", timer, r) - if r == 0 then - timer:set_repeat(8) - timer:again() - elseif r == 2 then - timer:stop() - timer:close() - else - timer:set_repeat(r / 2) - end - end, 4)) - end) - -end) |