aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/basic.lua8
-rw-r--r--tests/cancel.lua2
-rw-r--r--tests/deadlock.lua2
-rw-r--r--tests/error.lua4
-rw-r--r--tests/fifo.lua4
-rw-r--r--tests/keeper.lua36
-rw-r--r--tests/linda_perf.lua6
-rw-r--r--tests/tobeclosed.lua12
8 files changed, 37 insertions, 37 deletions
diff --git a/tests/basic.lua b/tests/basic.lua
index a9c85cc..9aaad97 100644
--- a/tests/basic.lua
+++ b/tests/basic.lua
@@ -163,7 +163,7 @@ PRINT(" "..st)
163assert(st == "cancelled", "st is '" .. st .. "' instead of 'cancelled'") 163assert(st == "cancelled", "st is '" .. st .. "' instead of 'cancelled'")
164 164
165-- cancellation of lanes waiting on a linda 165-- cancellation of lanes waiting on a linda
166local limited = lanes_linda("limited") 166local limited = lanes_linda{name = "limited"}
167assert.fails(function() limited:limit("key", -1) end) 167assert.fails(function() limited:limit("key", -1) end)
168assert.failsnot(function() limited:limit("key", 1) end) 168assert.failsnot(function() limited:limit("key", 1) end)
169-- [[################################################ 169-- [[################################################
@@ -255,7 +255,7 @@ local chunk= function(linda)
255 WR("chunk ", "Lane ends!\n") 255 WR("chunk ", "Lane ends!\n")
256end 256end
257 257
258local linda = lanes_linda("communications") 258local linda = lanes_linda{name = "communications"}
259assert(type(linda) == "userdata" and tostring(linda) == "Linda: communications") 259assert(type(linda) == "userdata" and tostring(linda) == "Linda: communications")
260 -- 260 --
261 -- ["->"] master -> slave 261 -- ["->"] master -> slave
@@ -410,7 +410,7 @@ local tc = lanes.gen("io", { name = 'auto', gc_cb = gc_cb },
410 end 410 end
411) 411)
412 412
413local linda= lanes_linda("criss cross") 413local linda= lanes_linda{name = "criss cross"}
414 414
415local a,b= tc(linda, "A","B"), tc(linda, "B","A") -- launching two lanes, twisted comms 415local a,b= tc(linda, "A","B"), tc(linda, "B","A") -- launching two lanes, twisted comms
416 416
@@ -461,7 +461,7 @@ local function chunk2(linda)
461 linda:send("up", function() return ":)" end, "ok2") 461 linda:send("up", function() return ":)" end, "ok2")
462end 462end
463 463
464local linda = lanes_linda("auto") 464local linda = lanes_linda{name = "auto"}
465local t2 = lanes.gen("debug,string,io", { name = 'auto', gc_cb = gc_cb }, chunk2)(linda) -- prepare & launch 465local t2 = lanes.gen("debug,string,io", { name = 'auto', gc_cb = gc_cb }, chunk2)(linda) -- prepare & launch
466linda:send("down", function(linda) linda:send("up", "ready!") end, 466linda:send("down", function(linda) linda:send("up", "ready!") end,
467 "ok") 467 "ok")
diff --git a/tests/cancel.lua b/tests/cancel.lua
index 80e6c6a..66957c3 100644
--- a/tests/cancel.lua
+++ b/tests/cancel.lua
@@ -148,7 +148,7 @@ local protectedBody = function(...)
148 local paramLessClosure = function() laneBody(unpack(params)) end 148 local paramLessClosure = function() laneBody(unpack(params)) end
149 local status, message = xpcall(paramLessClosure, errorHandler) 149 local status, message = xpcall(paramLessClosure, errorHandler)
150 if status == false then 150 if status == false then
151 print(" error handler rethrowing '" .. (ce == message and "cancel_error"or tostring(message)) .. "'") 151 print(" protectedBody rethrowing '" .. (ce == message and "cancel_error" or tostring(message)) .. "'")
152 -- if the error isn't rethrown, the lane's finalizer won't get it 152 -- if the error isn't rethrown, the lane's finalizer won't get it
153 error(message) 153 error(message)
154 end 154 end
diff --git a/tests/deadlock.lua b/tests/deadlock.lua
index d028e83..9b93e3b 100644
--- a/tests/deadlock.lua
+++ b/tests/deadlock.lua
@@ -16,7 +16,7 @@ print "let's begin"
16local do_extra_stuff = true 16local do_extra_stuff = true
17 17
18if do_extra_stuff then 18if do_extra_stuff then
19 local linda = lanes.linda "deadlock_linda" 19 local linda = lanes.linda{name = "deadlock_linda"}
20 -- just something to make send() succeed and receive() fail 20 -- just something to make send() succeed and receive() fail
21 local payload = { io.flush } 21 local payload = { io.flush }
22 22
diff --git a/tests/error.lua b/tests/error.lua
index 306c51d..28cfff1 100644
--- a/tests/error.lua
+++ b/tests/error.lua
@@ -106,11 +106,11 @@ end
106 106
107local lane_error_as_string = "'lane error as string'" 107local lane_error_as_string = "'lane error as string'"
108local lane_error_as_table = setmetatable({"lane error as table"}, make_table_error_mt()) 108local lane_error_as_table = setmetatable({"lane error as table"}, make_table_error_mt())
109local lane_error_as_linda = lanes.linda("'lane error'") 109local lane_error_as_linda = lanes.linda{name = "'lane error'"}
110 110
111local finalizer_error_as_string = "'finalizer error as string'" 111local finalizer_error_as_string = "'finalizer error as string'"
112local finalizer_error_as_table = setmetatable({"finalizer error as table"}, make_table_error_mt()) 112local finalizer_error_as_table = setmetatable({"finalizer error as table"}, make_table_error_mt())
113local finalizer_error_as_linda = lanes.linda("'finalizer error'") 113local finalizer_error_as_linda = lanes.linda{name = "'finalizer error'"}
114 114
115local test_settings = {} 115local test_settings = {}
116local configure_tests = function() 116local configure_tests = function()
diff --git a/tests/fifo.lua b/tests/fifo.lua
index 9efcbd9..1317a9f 100644
--- a/tests/fifo.lua
+++ b/tests/fifo.lua
@@ -6,10 +6,10 @@
6 6
7local lanes = require "lanes".configure{shutdown_timeout=3,with_timers=true} 7local lanes = require "lanes".configure{shutdown_timeout=3,with_timers=true}
8 8
9local atomic_linda = lanes.linda( "atom") 9local atomic_linda = lanes.linda{name = "atom"}
10local atomic_inc= lanes.genatomic( atomic_linda, "FIFO_n") 10local atomic_inc= lanes.genatomic( atomic_linda, "FIFO_n")
11 11
12local fifo_linda = lanes.linda( "fifo") 12local fifo_linda = lanes.linda{name = "fifo"}
13 13
14-- Lua 5.1 support 14-- Lua 5.1 support
15local table_unpack = table.unpack or unpack 15local table_unpack = table.unpack or unpack
diff --git a/tests/keeper.lua b/tests/keeper.lua
index f566927..4742732 100644
--- a/tests/keeper.lua
+++ b/tests/keeper.lua
@@ -40,14 +40,14 @@ if true then
40 end 40 end
41 41
42 -- should succeed 42 -- should succeed
43 assert.failsnot(function() createLinda("zero", 0) end) 43 assert.failsnot(function() createLinda{name = "zero", group = 0} end)
44 assert.failsnot(function() createLinda("one", 1) end) 44 assert.failsnot(function() createLinda{name = "one", group = 1} end)
45 assert.failsnot(function() createLinda("two", 2) end) 45 assert.failsnot(function() createLinda{name = "two", group = 2} end)
46 assert.failsnot(function() createLinda("three", 3) end) 46 assert.failsnot(function() createLinda{name = "three", group = 3} end)
47 -- should fail (and not create the lindas) 47 -- should fail (and not create the lindas)
48 assert.fails(function() createLinda("minus 1", -1) end) 48 assert.fails(function() createLinda{name = "minus 1", group = -1} end)
49 assert.fails(function() createLinda("none") end) 49 assert.fails(function() createLinda{name = "none"} end)
50 assert.fails(function() createLinda("four", 4) end) 50 assert.fails(function() createLinda{name = "four", group = 4} end)
51 51
52end 52end
53-- should only collect the 4 successfully created lindas 53-- should only collect the 4 successfully created lindas
@@ -58,11 +58,11 @@ DONE()
58if true then 58if true then
59 PRINT "=========================================================================================" 59 PRINT "========================================================================================="
60 PRINT "Linda names test:" 60 PRINT "Linda names test:"
61 local unnamedLinda1 = lanes.linda(1) 61 local unnamedLinda1 = lanes.linda{group = 1}
62 local unnamedLinda2 = lanes.linda("", 2) 62 local unnamedLinda2 = lanes.linda{name = "", group = 2}
63 local veeeerrrryyyylooongNamedLinda3 = lanes.linda( "veeeerrrryyyylooongNamedLinda", 3) 63 local veeeerrrryyyylooongNamedLinda3 = lanes.linda{ name = "veeeerrrryyyylooongNamedLinda", group = 3}
64 assert(tostring(veeeerrrryyyylooongNamedLinda3) == "Linda: veeeerrrryyyylooongNamedLinda") 64 assert(tostring(veeeerrrryyyylooongNamedLinda3) == "Linda: veeeerrrryyyylooongNamedLinda")
65 local shortNamedLinda0 = lanes.linda( "short", 0) 65 local shortNamedLinda0 = lanes.linda{name = "short", group = 0}
66 assert(tostring(shortNamedLinda0) == "Linda: short") 66 assert(tostring(shortNamedLinda0) == "Linda: short")
67 PRINT(shortNamedLinda0, unnamedLinda1, unnamedLinda2, veeeerrrryyyylooongNamedLinda3) 67 PRINT(shortNamedLinda0, unnamedLinda1, unnamedLinda2, veeeerrrryyyylooongNamedLinda3)
68end 68end
@@ -74,12 +74,12 @@ DONE()
74if true then 74if true then
75 PRINT "=========================================================================================" 75 PRINT "========================================================================================="
76 PRINT "Linda GC test:" 76 PRINT "Linda GC test:"
77 local a = lanes.linda("A", 1) 77 local a = lanes.linda{name = "A", group = 1}
78 local b = lanes.linda("B", 2) 78 local b = lanes.linda{name = "B", group = 2}
79 local c = lanes.linda("C", 3) 79 local c = lanes.linda{name = "C", group = 3}
80 80
81 -- store lindas in each other and in themselves 81 -- store lindas in each other and in themselves
82 a:set("here", lanes.linda("temporary linda", 0)) 82 a:set("here", lanes.linda{name = "temporary linda", group = 0})
83 b:set("here", a, b, c) 83 b:set("here", a, b, c)
84 c:set("here", a, b, c) 84 c:set("here", a, b, c)
85 85
@@ -120,13 +120,13 @@ if true then
120 end 120 end
121 121
122 -- 122 --
123 local lindaA= lanes.linda( "A", 1) 123 local lindaA= lanes.linda{name = "A", group = 1}
124 local A= keeper( lindaA ) 124 local A= keeper( lindaA )
125 125
126 local lindaB= lanes.linda( "B", 2) 126 local lindaB= lanes.linda{name = "B", group = 2}
127 local B= keeper( lindaB ) 127 local B= keeper( lindaB )
128 128
129 local lindaC= lanes.linda( "C", 3) 129 local lindaC= lanes.linda{name = "C", group = 3}
130 local C= keeper( lindaC ) 130 local C= keeper( lindaC )
131 PRINT("Created", lindaA, lindaB, lindaC) 131 PRINT("Created", lindaA, lindaB, lindaC)
132 132
diff --git a/tests/linda_perf.lua b/tests/linda_perf.lua
index 107fd25..83b8921 100644
--- a/tests/linda_perf.lua
+++ b/tests/linda_perf.lua
@@ -22,7 +22,7 @@ if true then
22 do 22 do
23 print "############################################ tests get/set" 23 print "############################################ tests get/set"
24 -- linda:get throughput 24 -- linda:get throughput
25 local l = lanes.linda("get/set", 1) 25 local l = lanes.linda{name = "get/set", group = 1}
26 local batch = {} 26 local batch = {}
27 for i = 1,1000 do 27 for i = 1,1000 do
28 table.insert(batch, i) 28 table.insert(batch, i)
@@ -90,7 +90,7 @@ local group_uid = 1
90local function ziva1( preloop, loop, batch) 90local function ziva1( preloop, loop, batch)
91 -- prefill the linda a bit to increase fifo stress 91 -- prefill the linda a bit to increase fifo stress
92 local top = math.max( preloop, loop) 92 local top = math.max( preloop, loop)
93 local l = lanes.linda("ziva1("..preloop..":"..loop..":"..batch..")", group_uid) 93 local l = lanes.linda{name = "ziva1("..preloop..":"..loop..":"..batch..")", group = group_uid}
94 group_uid = (group_uid % config.nb_user_keepers) + 1 94 group_uid = (group_uid % config.nb_user_keepers) + 1
95 local t1 = lanes.now_secs() 95 local t1 = lanes.now_secs()
96 for i = 1, preloop do 96 for i = 1, preloop do
@@ -165,7 +165,7 @@ end
165 165
166-- sequential write/read (no parallelization involved) 166-- sequential write/read (no parallelization involved)
167local function ziva2( preloop, loop, batch) 167local function ziva2( preloop, loop, batch)
168 local l = lanes.linda("ziva2("..preloop..":"..loop..":"..tostring(batch)..")", group_uid) 168 local l = lanes.linda{name = "ziva2("..preloop..":"..loop..":"..tostring(batch)..")", group = group_uid}
169 group_uid = (group_uid % config.nb_user_keepers) + 1 169 group_uid = (group_uid % config.nb_user_keepers) + 1
170 -- prefill the linda a bit to increase fifo stress 170 -- prefill the linda a bit to increase fifo stress
171 local top, step = math.max( preloop, loop), batch or 1 171 local top, step = math.max( preloop, loop), batch or 1
diff --git a/tests/tobeclosed.lua b/tests/tobeclosed.lua
index ef09df3..447b936 100644
--- a/tests/tobeclosed.lua
+++ b/tests/tobeclosed.lua
@@ -36,7 +36,7 @@ do
36 WR("f closing ", linda_) 36 WR("f closing ", linda_)
37 closed_by_f = true 37 closed_by_f = true
38 end 38 end
39 local lf <close> = lanes.linda("closed by f", close_handler_f) 39 local lf <close> = lanes.linda{name = "closed by f", close_handler = close_handler_f}
40 40
41 local close_handler_t = setmetatable({}, 41 local close_handler_t = setmetatable({},
42 { 42 {
@@ -46,7 +46,7 @@ do
46 end 46 end
47 } 47 }
48 ) 48 )
49 local lt <close> = lanes.linda("closed by t", close_handler_t) 49 local lt <close> = lanes.linda{name = "closed by t", close_handler = close_handler_t}
50 end 50 end
51 assert(closed_by_f == true) 51 assert(closed_by_f == true)
52 assert(closed_by_t == true) 52 assert(closed_by_t == true)
@@ -58,13 +58,13 @@ end
58WR "================================================================================================" 58WR "================================================================================================"
59WR "Through Linda" 59WR "Through Linda"
60do 60do
61 local l = lanes.linda("channel") 61 local l = lanes.linda{name = "channel"}
62 62
63 local close_handler_f = function(linda_, err_) 63 local close_handler_f = function(linda_, err_)
64 WR("f closing ", linda_) 64 WR("f closing ", linda_)
65 linda_:set("closed", true) 65 linda_:set("closed", true)
66 end 66 end
67 local l_in = lanes.linda("voyager", close_handler_f) 67 local l_in = lanes.linda{name = "voyager", close_handler = close_handler_f}
68 l:set("trip", l_in) 68 l:set("trip", l_in)
69 69
70 do 70 do
@@ -99,7 +99,7 @@ end
99WR "================================================================================================" 99WR "================================================================================================"
100WR "Linda closing through Lane" 100WR "Linda closing through Lane"
101do 101do
102 local l = lanes.linda("channel") 102 local l = lanes.linda{name = "channel"}
103 local lane_body = function(l_arg_) 103 local lane_body = function(l_arg_)
104 WR "In lane body" 104 WR "In lane body"
105 -- linda obtained through a linda 105 -- linda obtained through a linda
@@ -114,7 +114,7 @@ do
114 local _count, _closed = linda_:get("closed") 114 local _count, _closed = linda_:get("closed")
115 linda_:set("closed", (_closed or 0) + 1) 115 linda_:set("closed", (_closed or 0) + 1)
116 end 116 end
117 local l_in = lanes.linda("voyager", close_handler_f) 117 local l_in = lanes.linda{name = "voyager", close_handler = close_handler_f}
118 l:set("trip", l_in) 118 l:set("trip", l_in)
119 119
120 do 120 do