aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBenoit Germain <bnt.germain@gmail.com>2011-02-12 17:06:03 +0100
committerBenoit Germain <bnt.germain@gmail.com>2011-02-12 17:06:03 +0100
commita661736f7984292a41d71847de68590f6b8ca08a (patch)
tree43e0799c20e835f1cc2d8c5fa1324b64301763e0 /tests
parentc91a03bd956bf19848253bded8217687ccd2ad81 (diff)
downloadlanes-a661736f7984292a41d71847de68590f6b8ca08a.tar.gz
lanes-a661736f7984292a41d71847de68590f6b8ca08a.tar.bz2
lanes-a661736f7984292a41d71847de68590f6b8ca08a.zip
Changed idfunc signature and contract to clarify that fact it is not lua-callable and to be able to require the module it was exported from in the target lanes.
Diffstat (limited to 'tests')
-rw-r--r--tests/basic.lua17
1 files changed, 5 insertions, 12 deletions
diff --git a/tests/basic.lua b/tests/basic.lua
index b1e8fd3..352e029 100644
--- a/tests/basic.lua
+++ b/tests/basic.lua
@@ -171,7 +171,7 @@ local function PEEK() return linda:get("<-") end
171local function SEND(...) linda:send( "->", ... ) end 171local function SEND(...) linda:send( "->", ... ) end
172local function RECEIVE() return linda:receive( "<-" ) end 172local function RECEIVE() return linda:receive( "<-" ) end
173 173
174local t= lanes_gen("io",chunk)(linda) -- prepare & launch 174local t= lanes_gen("io,package",chunk)(linda) -- prepare & launch
175 175
176SEND(1); WR( "1 sent\n" ) 176SEND(1); WR( "1 sent\n" )
177SEND(2); WR( "2 sent\n" ) 177SEND(2); WR( "2 sent\n" )
@@ -230,7 +230,7 @@ local tc= lanes_gen( "io",
230 end 230 end
231 STAGE("Hello") 231 STAGE("Hello")
232 STAGE("I was here first!") 232 STAGE("I was here first!")
233 STAGE("So waht?") 233 STAGE("So what?")
234 end 234 end
235) 235)
236 236
@@ -247,7 +247,6 @@ local upvalue="123"
247 247
248local function chunk2( linda ) 248local function chunk2( linda )
249 assert( upvalue=="123" ) -- even when running as separate thread 249 assert( upvalue=="123" ) -- even when running as separate thread
250
251 -- function name & line number should be there even as separate thread 250 -- function name & line number should be there even as separate thread
252 -- 251 --
253 local info= debug.getinfo(1) -- 1 = us 252 local info= debug.getinfo(1) -- 1 = us
@@ -256,17 +255,14 @@ local function chunk2( linda )
256 255
257 assert( info.nups == 2 ) -- one upvalue + PRINT 256 assert( info.nups == 2 ) -- one upvalue + PRINT
258 assert( info.what == "Lua" ) 257 assert( info.what == "Lua" )
259
260 --assert( info.name == "chunk2" ) -- name does not seem to come through 258 --assert( info.name == "chunk2" ) -- name does not seem to come through
261 assert( string.match( info.source, "^@basic.lua$" ) ) 259 assert( string.match( info.source, "^@.*basic.lua$" ) )
262 assert( string.match( info.short_src, "^basic.lua$" ) ) 260 assert( string.match( info.short_src, "^.*basic.lua$" ) )
263
264 -- These vary so let's not be picky (they're there..) 261 -- These vary so let's not be picky (they're there..)
265 -- 262 --
266 assert( info.linedefined > 200 ) -- start of 'chunk2' 263 assert( info.linedefined > 200 ) -- start of 'chunk2'
267 assert( info.currentline > info.linedefined ) -- line of 'debug.getinfo' 264 assert( info.currentline > info.linedefined ) -- line of 'debug.getinfo'
268 assert( info.lastlinedefined > info.currentline ) -- end of 'chunk2' 265 assert( info.lastlinedefined > info.currentline ) -- end of 'chunk2'
269
270 local func,k= linda:receive( "down" ) 266 local func,k= linda:receive( "down" )
271 assert( type(func)=="function" ) 267 assert( type(func)=="function" )
272 assert( k=="down" ) 268 assert( k=="down" )
@@ -280,12 +276,9 @@ local function chunk2( linda )
280end 276end
281 277
282local linda= lanes.linda() 278local linda= lanes.linda()
283 279local t2= lanes_gen( "debug,string,io", chunk2 )(linda) -- prepare & launch
284local t2= lanes_gen( "debug,string", chunk2 )(linda) -- prepare & launch
285
286linda:send( "down", function(linda) linda:send( "up", "ready!" ) end, 280linda:send( "down", function(linda) linda:send( "up", "ready!" ) end,
287 "ok" ) 281 "ok" )
288
289-- wait to see if the tiny function gets executed 282-- wait to see if the tiny function gets executed
290-- 283--
291local s= linda:receive( "up" ) 284local s= linda:receive( "up" )