aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBenoit Germain <bnt.germain@gmail.com>2011-02-14 21:20:24 +0100
committerBenoit Germain <bnt.germain@gmail.com>2011-02-14 21:20:24 +0100
commitafb2da4789cdaddc5a0c3c9c2d57ccd36bcc74c7 (patch)
tree5f4208ca75f46848f793441530d16ca019d4bd00 /tests
parentbaeb379c2e4eb436ecb0bcc4d88cb50930ef378e (diff)
downloadlanes-afb2da4789cdaddc5a0c3c9c2d57ccd36bcc74c7.tar.gz
lanes-afb2da4789cdaddc5a0c3c9c2d57ccd36bcc74c7.tar.bz2
lanes-afb2da4789cdaddc5a0c3c9c2d57ccd36bcc74c7.zip
Fixed application hang-up because keeper state was not released in case of errors thrown by inter-state data copy for unsupported types
Diffstat (limited to 'tests')
-rw-r--r--tests/appendud.lua6
-rw-r--r--tests/errhangtest.lua13
-rw-r--r--tests/irayo_closure.lua10
3 files changed, 22 insertions, 7 deletions
diff --git a/tests/appendud.lua b/tests/appendud.lua
index afea0e9..65d0798 100644
--- a/tests/appendud.lua
+++ b/tests/appendud.lua
@@ -31,18 +31,18 @@ local _ud = {
31 31
32 32
33function appendud(tab, ud) 33function appendud(tab, ud)
34io.stderr:write "Starting" 34 io.stderr:write "Starting"
35 tab:beginupdate() set_finalizer( function() tab:endupdate() end ) 35 tab:beginupdate() set_finalizer( function() tab:endupdate() end )
36 ud:lock() set_finalizer( function() ud:unlock() end ) 36 ud:lock() set_finalizer( function() ud:unlock() end )
37 for i = 1,#ud do 37 for i = 1,#ud do
38 tab[#tab+1] = ud[i] 38 tab[#tab+1] = ud[i]
39 end 39 end
40io.stderr:write "Ending" 40 io.stderr:write "Ending"
41 return tab -- need to return 'tab' since we're running in a separate thread 41 return tab -- need to return 'tab' since we're running in a separate thread
42 -- ('tab' is passed over lanes by value, not by reference) 42 -- ('tab' is passed over lanes by value, not by reference)
43end 43end
44 44
45local t,err= lanes.gen( appendud )( _tab, _ud ) -- create & launch a thread 45local t,err= lanes.gen( "io", appendud )( _tab, _ud ) -- create & launch a thread
46assert(t) 46assert(t)
47assert(not err) 47assert(not err)
48 48
diff --git a/tests/errhangtest.lua b/tests/errhangtest.lua
new file mode 100644
index 0000000..ddc1bfb
--- /dev/null
+++ b/tests/errhangtest.lua
@@ -0,0 +1,13 @@
1lanes = require('lanes')
2
3local linda = lanes.linda()
4
5local coro = coroutine.create(function() end)
6
7-- we are not allowed to send coroutines through a lanes
8-- however, this should raise an error, not hang the program...
9print( pcall(linda.send,linda, 'test', "oh boy"))
10print( pcall(linda.send,linda, 'test', coro))
11res = linda:receive('test')
12print( res)
13-- linda:send( 'test', coro)
diff --git a/tests/irayo_closure.lua b/tests/irayo_closure.lua
index faf08fd..3a82302 100644
--- a/tests/irayo_closure.lua
+++ b/tests/irayo_closure.lua
@@ -20,11 +20,13 @@ local function testrun()
20 return true 20 return true
21end 21end
22 22
23-- Should also work without these lines, but currently doesn't (bug in Lanes, 23-- When some function dereferences a global key, the asssociated global in the source state
24-- a function thrown over isn't connected to receiving lane's globals) 24-- isn't sent over the target lane
25-- therefore, the necessary functions must either be pulled as upvalues (hence locals)
26-- or the globals must exist in the target lanes because the modules have been required there
25-- 27--
26--local print=print 28local print=print
27--local assert=assert 29local assert=assert
28 30
29local function useclosurehere() 31local function useclosurehere()
30 assert( print ) 32 assert( print )