aboutsummaryrefslogtreecommitdiff
path: root/tests/irayo_closure.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tests/irayo_closure.lua')
-rw-r--r--tests/irayo_closure.lua35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/irayo_closure.lua b/tests/irayo_closure.lua
new file mode 100644
index 0000000..faf08fd
--- /dev/null
+++ b/tests/irayo_closure.lua
@@ -0,0 +1,35 @@
1--
2-- Bugs filed by irayo Jul-2008
3--
4--[[
5"Another issue I've noticed is trying to pass a table with a function
6that uses closures in it as a global variable into a new lane. This
7causes a segmentation fault and it appears to be related to the
8luaG_inter_move function near line 835-836 or so in lanes.c, but I
9haven't investigated further.
10e.g. { globals = { data = 1, func = function() useclosurehere() end } }"
11]]
12
13require "lanes"
14
15local function testrun()
16 assert( print )
17 assert( data==1 )
18 assert( type(func)=="function" )
19 func() -- "using the closure"
20 return true
21end
22
23-- Should also work without these lines, but currently doesn't (bug in Lanes,
24-- a function thrown over isn't connected to receiving lane's globals)
25--
26--local print=print
27--local assert=assert
28
29local function useclosurehere()
30 assert( print )
31 print "using the closure"
32end
33
34local lane= lanes.gen( "", { globals = { data=1, func=useclosurehere } }, testrun )()
35print(lane[1])