summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/luv/tests/test-async.lua
diff options
context:
space:
mode:
author ImJezze <jezze@gmx.net>2016-02-21 11:48:45 +0100
committer ImJezze <jezze@gmx.net>2016-02-21 11:48:45 +0100
commitcc24a339d8c0517259084b5c178d784626ba965c (patch)
tree9868e9687b5802ae0a3733712a3bbeb3bc75c953 /3rdparty/luv/tests/test-async.lua
parentb5daabda5495dea5c50e17961ecfed2ea8619d76 (diff)
Merge remote-tracking branch 'refs/remotes/mamedev/master'
Second attempt
Diffstat (limited to '3rdparty/luv/tests/test-async.lua')
-rw-r--r--3rdparty/luv/tests/test-async.lua32
1 files changed, 32 insertions, 0 deletions
diff --git a/3rdparty/luv/tests/test-async.lua b/3rdparty/luv/tests/test-async.lua
new file mode 100644
index 00000000000..88527cdb88d
--- /dev/null
+++ b/3rdparty/luv/tests/test-async.lua
@@ -0,0 +1,32 @@
+return require('lib/tap')(function (test)
+
+ test("test pass async between threads", function(p, p, expect, uv)
+ local before = os.time()
+ local async
+ async = uv.new_async(expect(function (a,b,c)
+ p('in async notify callback')
+ p(a,b,c)
+ assert(a=='a')
+ assert(b==true)
+ assert(c==250)
+ uv.close(async)
+ end))
+ local args = {500, 'string', nil, false, 5, "helloworld",async}
+ local unpack = unpack or table.unpack
+ uv.new_thread(function(num,s,null,bool,five,hw,asy)
+ local uv = require'luv'
+ assert(type(num) == "number")
+ assert(type(s) == "string")
+ assert(null == nil)
+ assert(bool == false)
+ assert(five == 5)
+ assert(hw == 'helloworld')
+ assert(type(asy)=='userdata')
+ assert(uv.async_send(asy,'a',true,250)==0)
+ uv.sleep(1000)
+ end, unpack(args)):join()
+ local elapsed = (os.time() - before) * 1000
+ assert(elapsed >= 1000, "elapsed should be at least delay ")
+ end)
+
+end)