diff options
| author | Benoit Germain <benoit.germain@ubisoft.com> | 2024-04-11 15:14:52 +0200 |
|---|---|---|
| committer | Benoit Germain <benoit.germain@ubisoft.com> | 2024-04-11 15:14:52 +0200 |
| commit | adaa36dbec1ce9aaafd61873b9d3d898a8c240cf (patch) | |
| tree | 4c81e8f5983c3d696a636e2cc433ce7c0a9c3dd8 /tests/basic.lua | |
| parent | 1d310e6ecb6e156598337612f16573d9cd284f5e (diff) | |
| download | lanes-adaa36dbec1ce9aaafd61873b9d3d898a8c240cf.tar.gz lanes-adaa36dbec1ce9aaafd61873b9d3d898a8c240cf.tar.bz2 lanes-adaa36dbec1ce9aaafd61873b9d3d898a8c240cf.zip | |
Bring all interesting fixes from the C++ implementation back into the C implementation
Diffstat (limited to 'tests/basic.lua')
| -rw-r--r-- | tests/basic.lua | 14 |
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) | |||
| 154 | assert( st == "cancelled" ) | 154 | assert( st == "cancelled" ) |
| 155 | 155 | ||
| 156 | -- cancellation of lanes waiting on a linda | 156 | -- cancellation of lanes waiting on a linda |
| 157 | local limited = lanes.linda() | 157 | local limited = lanes.linda("limited") |
| 158 | limited:limit( "key", 1) | 158 | limited:limit( "key", 1) |
| 159 | -- [[################################################ | 159 | -- [[################################################ |
| 160 | limited:send( "key", "hello") -- saturate linda | 160 | limited:send( "key", "hello") -- saturate linda |
| @@ -234,7 +234,7 @@ local chunk= function( linda ) | |||
| 234 | WR( "Lane ends!\n" ) | 234 | WR( "Lane ends!\n" ) |
| 235 | end | 235 | end |
| 236 | 236 | ||
| 237 | local linda= lanes_linda() | 237 | local linda= lanes_linda("communications") |
| 238 | assert( type(linda) == "userdata" ) | 238 | assert( 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" ) | |||
| 278 | assert( complex_table[1] == complex_table[3] and complex_table[2] == complex_table[4]) | 278 | assert( complex_table[1] == complex_table[3] and complex_table[2] == complex_table[4]) |
| 279 | WR( table.concat( {complex_table[1][1],complex_table[2][1],complex_table[3][1],complex_table[4][1]},", ")) | 279 | WR( table.concat( {complex_table[1][1],complex_table[2][1],complex_table[3][1],complex_table[4][1]},", ")) |
| 280 | 280 | ||
| 281 | WR("collectgarbage") | ||
| 281 | t = nil | 282 | t = nil |
| 282 | collectgarbage() | 283 | collectgarbage() |
| 283 | -- wait | 284 | -- wait |
| 284 | linda: receive( 1, "wait") | 285 | WR("waiting 1s") |
| 286 | linda: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] ) |
| 337 | end | 339 | end |
| 338 | 340 | ||
| 341 | WR("collectgarbage") | ||
| 339 | collectgarbage() | 342 | collectgarbage() |
| 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 | ||
| 364 | local linda= lanes_linda() | 367 | local linda= lanes_linda("criss cross") |
| 365 | 368 | ||
| 366 | local a,b= tc(linda, "A","B"), tc(linda, "B","A") -- launching two lanes, twisted comms | 369 | local a,b= tc(linda, "A","B"), tc(linda, "B","A") -- launching two lanes, twisted comms |
| 367 | 370 | ||
| 368 | local _= a[1],b[1] -- waits until they are both ready | 371 | local _= a[1],b[1] -- waits until they are both ready |
| 369 | 372 | ||
| 373 | WR("collectgarbage") | ||
| 370 | a, b = nil | 374 | a, b = nil |
| 371 | collectgarbage() | 375 | collectgarbage() |
| 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" ) |
| 409 | end | 413 | end |
| 410 | 414 | ||
| 411 | local linda= lanes.linda() | 415 | local linda= lanes.linda("linda") |
| 412 | local t2= lanes_gen( "debug,string,io", {gc_cb = gc_cb}, chunk2 )(linda) -- prepare & launch | 416 | local t2= lanes_gen( "debug,string,io", {gc_cb = gc_cb}, chunk2 )(linda) -- prepare & launch |
| 413 | linda:send( "down", function(linda) linda:send( "up", "ready!" ) end, | 417 | linda:send( "down", function(linda) linda:send( "up", "ready!" ) end, |
| 414 | "ok" ) | 418 | "ok" ) |
