aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/cancel.lua1
-rw-r--r--tests/cyclic.lua3
-rw-r--r--tests/fifo.lua4
-rw-r--r--tests/finalizer.lua1
-rw-r--r--tests/keeper.lua1
-rw-r--r--tests/linda_perf.lua2
-rw-r--r--tests/parallel_os_calls.lua8
-rw-r--r--tests/pingpong.lua4
-rw-r--r--tests/rupval.lua15
9 files changed, 32 insertions, 7 deletions
diff --git a/tests/cancel.lua b/tests/cancel.lua
index 92ab439..42ae839 100644
--- a/tests/cancel.lua
+++ b/tests/cancel.lua
@@ -15,6 +15,7 @@ local SLEEP = function(...)
15 local lanes = require "lanes" 15 local lanes = require "lanes"
16 local k, v = lanes.sleep(...) 16 local k, v = lanes.sleep(...)
17 assert(k == nil and v == "timeout") 17 assert(k == nil and v == "timeout")
18 return true
18 end 19 end
19 local sleeper = lanes.gen("*", sleeperBody)(...) 20 local sleeper = lanes.gen("*", sleeperBody)(...)
20 -- then wait for the lane to terminate 21 -- then wait for the lane to terminate
diff --git a/tests/cyclic.lua b/tests/cyclic.lua
index 656fde3..553d2a9 100644
--- a/tests/cyclic.lua
+++ b/tests/cyclic.lua
@@ -30,6 +30,7 @@ local function lane1()
30 WR( "Via upvalue: ", same(a,b[1]), same(a[1],b) ) 30 WR( "Via upvalue: ", same(a,b[1]), same(a[1],b) )
31 assert( a[1]==b ) 31 assert( a[1]==b )
32 assert( b[1]==a ) 32 assert( b[1]==a )
33 return true
33end 34end
34local L1= lanes.gen( "io", lane1 )() 35local L1= lanes.gen( "io", lane1 )()
35 -- ...running 36 -- ...running
@@ -40,6 +41,7 @@ local function lane2( aa, bb )
40 WR( "Via parameters:", same(aa,bb[1]), same(aa[1],bb) ) 41 WR( "Via parameters:", same(aa,bb[1]), same(aa[1],bb) )
41 assert( aa[1]==bb ) 42 assert( aa[1]==bb )
42 assert( bb[1]==aa ) 43 assert( bb[1]==aa )
44 return true
43end 45end
44local L2= lanes.gen( "io", lane2 )( a, b ) 46local L2= lanes.gen( "io", lane2 )( a, b )
45 -- ...running 47 -- ...running
@@ -52,6 +54,7 @@ c.a= c
52local function lane3( cc ) 54local function lane3( cc )
53 WR( "Directly recursive: ", same(cc, cc.a) ) 55 WR( "Directly recursive: ", same(cc, cc.a) )
54 assert( cc and cc.a==cc ) 56 assert( cc and cc.a==cc )
57 return true
55end 58end
56local L3= lanes.gen("io", lane3)(c) 59local L3= lanes.gen("io", lane3)(c)
57 60
diff --git a/tests/fifo.lua b/tests/fifo.lua
index d741931..e1bfeae 100644
--- a/tests/fifo.lua
+++ b/tests/fifo.lua
@@ -82,4 +82,6 @@ print( B:receive( 2.0))
82-- by multiple threads (other parts will be copied but the 'linda' 82-- by multiple threads (other parts will be copied but the 'linda'
83-- handle is shared userdata and will thus point to the single place) 83-- handle is shared userdata and will thus point to the single place)
84lanes.timer_lane:cancel() -- hard cancel, 0 timeout 84lanes.timer_lane:cancel() -- hard cancel, 0 timeout
85lanes.timer_lane:join() \ No newline at end of file 85local status, err = lanes.timer_lane:join()
86assert(status == nil and err == lanes.cancel_error, "status="..tostring(status).." err="..tostring(err))
87print "TEST OK"
diff --git a/tests/finalizer.lua b/tests/finalizer.lua
index 2acc39d..3158c65 100644
--- a/tests/finalizer.lua
+++ b/tests/finalizer.lua
@@ -39,6 +39,7 @@ local function lane(error_)
39 error(error_, 0) -- exception here; the value needs NOT be a string 39 error(error_, 0) -- exception here; the value needs NOT be a string
40 end 40 end
41 -- no exception 41 -- no exception
42 return true
42end 43end
43 44
44-- 45--
diff --git a/tests/keeper.lua b/tests/keeper.lua
index 0220eba..2f731f0 100644
--- a/tests/keeper.lua
+++ b/tests/keeper.lua
@@ -155,6 +155,7 @@ if true then
155 c.some= 3 155 c.some= 3
156 assert( c.some==3 ) 156 assert( c.some==3 )
157 PRINT("c.some == " .. c.some) 157 PRINT("c.some == " .. c.some)
158 return true
158 end 159 end
159 160
160 PRINT("lane started") 161 PRINT("lane started")
diff --git a/tests/linda_perf.lua b/tests/linda_perf.lua
index 0b25989..4b0c005 100644
--- a/tests/linda_perf.lua
+++ b/tests/linda_perf.lua
@@ -56,6 +56,7 @@ local eater = function( l, loop)
56 -- print "loop is over" 56 -- print "loop is over"
57 key, val = l:receive( "done") 57 key, val = l:receive( "done")
58 print("eater: done ("..val..")") 58 print("eater: done ("..val..")")
59 return true
59end 60end
60 61
61-- ################################################################################################# 62-- #################################################################################################
@@ -73,6 +74,7 @@ local gobbler = function( l, loop, batch)
73 print "loop is over" 74 print "loop is over"
74 key, val = l:receive( "done") 75 key, val = l:receive( "done")
75 print("gobbler: done ("..val..")") 76 print("gobbler: done ("..val..")")
77 return true
76end 78end
77 79
78-- ################################################################################################# 80-- #################################################################################################
diff --git a/tests/parallel_os_calls.lua b/tests/parallel_os_calls.lua
index 596053c..7e7de26 100644
--- a/tests/parallel_os_calls.lua
+++ b/tests/parallel_os_calls.lua
@@ -1,10 +1,10 @@
1local lanes = require "lanes".configure() 1local lanes = require "lanes".configure()
2print( os.date()) 2print( os.date())
3local linda = lanes.linda() 3local linda = lanes.linda()
4local l1 = lanes.gen("os,base", function() print "start sleeping" linda:receive(10, "null") print("finished_sleeping " .. os.date()) end)() 4local l1 = lanes.gen("os,base", function() print "start sleeping" linda:receive(3, "null") print("finished_sleeping " .. os.date()) return true end)()
5lanes.gen("os,base", function() print "start sleeping" linda:receive(9, "null") print("finished_sleeping " .. os.date()) end)() 5lanes.gen("os,base", function() print "start sleeping" linda:receive(2, "null") print("finished_sleeping " .. os.date()) end)()
6lanes.gen("os,base", function() print "start sleeping" linda:receive(9, "null") print("finished_sleeping " .. os.date()) end)() 6lanes.gen("os,base", function() print "start sleeping" linda:receive(2, "null") print("finished_sleeping " .. os.date()) end)()
7lanes.gen("os,base", function() print "start sleeping" linda:receive(9, "null") print("finished_sleeping " .. os.date()) end)() 7lanes.gen("os,base", function() print "start sleeping" linda:receive(2, "null") print("finished_sleeping " .. os.date()) end)()
8-- wait, else all lanes will get hard-cancelled at stat shutdown 8-- wait, else all lanes will get hard-cancelled at stat shutdown
9l1:join() 9l1:join()
10--[[ 10--[[
diff --git a/tests/pingpong.lua b/tests/pingpong.lua
index 30cd360..fdc60a6 100644
--- a/tests/pingpong.lua
+++ b/tests/pingpong.lua
@@ -21,6 +21,7 @@ local pingpong = function(name, qr, qs, start)
21 q:send(qs, val) 21 q:send(qs, val)
22 count = count + 1 22 count = count + 1
23 end 23 end
24 return true
24end 25end
25 26
26-- pingpong("L1", '0', '1', true) 27-- pingpong("L1", '0', '1', true)
@@ -28,4 +29,5 @@ local t1, err1 = lanes.gen("*", pingpong)("L1", 'a', 'b', true)
28local t2, err2 = lanes.gen("*", pingpong)("L2", 'b', 'a', false) 29local t2, err2 = lanes.gen("*", pingpong)("L2", 'b', 'a', false)
29 30
30t1:join() 31t1:join()
31t2:join() \ No newline at end of file 32t2:join()
33print "TEST OK"
diff --git a/tests/rupval.lua b/tests/rupval.lua
index 1079168..122e0ac 100644
--- a/tests/rupval.lua
+++ b/tests/rupval.lua
@@ -25,6 +25,19 @@ end
25 25
26local g = lanes.gen( "base", a) 26local g = lanes.gen( "base", a)
27 27
28local l = g(10) 28local l = g(7)
29local r = l:join() 29local r = l:join()
30assert(r == y)
30print(r) 31print(r)
32
33local l = g(8)
34local r = l:join()
35assert(r == z)
36print(r)
37
38local l = g(9)
39local r = l:join()
40assert(r == x)
41print(r)
42
43print "TEST OK"