aboutsummaryrefslogtreecommitdiff
path: root/tests/basic.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tests/basic.lua')
-rw-r--r--tests/basic.lua14
1 files changed, 9 insertions, 5 deletions
diff --git a/tests/basic.lua b/tests/basic.lua
index 385e22f..4b4fae6 100644
--- a/tests/basic.lua
+++ b/tests/basic.lua
@@ -154,7 +154,7 @@ PRINT(" "..st)
154assert( st == "cancelled" ) 154assert( st == "cancelled" )
155 155
156-- cancellation of lanes waiting on a linda 156-- cancellation of lanes waiting on a linda
157local limited = lanes.linda() 157local limited = lanes.linda("limited")
158limited:limit( "key", 1) 158limited:limit( "key", 1)
159-- [[################################################ 159-- [[################################################
160limited:send( "key", "hello") -- saturate linda 160limited:send( "key", "hello") -- saturate linda
@@ -234,7 +234,7 @@ local chunk= function( linda )
234 WR( "Lane ends!\n" ) 234 WR( "Lane ends!\n" )
235end 235end
236 236
237local linda= lanes_linda() 237local linda= lanes_linda("communications")
238assert( type(linda) == "userdata" ) 238assert( type(linda) == "userdata" )
239 -- 239 --
240 -- ["->"] master -> slave 240 -- ["->"] master -> slave
@@ -278,10 +278,12 @@ local complex_table = RECEIVE(); WR( type(complex_table).." received\n" )
278assert( complex_table[1] == complex_table[3] and complex_table[2] == complex_table[4]) 278assert( complex_table[1] == complex_table[3] and complex_table[2] == complex_table[4])
279WR( table.concat( {complex_table[1][1],complex_table[2][1],complex_table[3][1],complex_table[4][1]},", ")) 279WR( table.concat( {complex_table[1][1],complex_table[2][1],complex_table[3][1],complex_table[4][1]},", "))
280 280
281WR("collectgarbage")
281t = nil 282t = nil
282collectgarbage() 283collectgarbage()
283-- wait 284-- wait
284linda: receive( 1, "wait") 285WR("waiting 1s")
286linda:receive( 1, "wait")
285 287
286--############################################################## 288--##############################################################
287--############################################################## 289--##############################################################
@@ -336,6 +338,7 @@ for _, t in ipairs( stdlib_naming_tests) do
336 assert( f(t[1])[1] ) 338 assert( f(t[1])[1] )
337end 339end
338 340
341WR("collectgarbage")
339collectgarbage() 342collectgarbage()
340 343
341--############################################################## 344--##############################################################
@@ -361,12 +364,13 @@ local tc= lanes_gen( "io", {gc_cb = gc_cb},
361 end 364 end
362) 365)
363 366
364local linda= lanes_linda() 367local linda= lanes_linda("criss cross")
365 368
366local a,b= tc(linda, "A","B"), tc(linda, "B","A") -- launching two lanes, twisted comms 369local a,b= tc(linda, "A","B"), tc(linda, "B","A") -- launching two lanes, twisted comms
367 370
368local _= a[1],b[1] -- waits until they are both ready 371local _= a[1],b[1] -- waits until they are both ready
369 372
373WR("collectgarbage")
370a, b = nil 374a, b = nil
371collectgarbage() 375collectgarbage()
372 376
@@ -408,7 +412,7 @@ local function chunk2( linda )
408 linda:send( "up", function() return ":)" end, "ok2" ) 412 linda:send( "up", function() return ":)" end, "ok2" )
409end 413end
410 414
411local linda= lanes.linda() 415local linda= lanes.linda("linda")
412local t2= lanes_gen( "debug,string,io", {gc_cb = gc_cb}, chunk2 )(linda) -- prepare & launch 416local t2= lanes_gen( "debug,string,io", {gc_cb = gc_cb}, chunk2 )(linda) -- prepare & launch
413linda:send( "down", function(linda) linda:send( "up", "ready!" ) end, 417linda:send( "down", function(linda) linda:send( "up", "ready!" ) end,
414 "ok" ) 418 "ok" )