aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/fibonacci.lua32
-rw-r--r--tests/irayo_recursive.lua2
-rw-r--r--tests/keeper.lua14
-rw-r--r--tests/nameof.lua2
-rw-r--r--tests/nb_keepers.lua20
-rw-r--r--tests/parallel_os_calls.lua2
6 files changed, 46 insertions, 26 deletions
diff --git a/tests/fibonacci.lua b/tests/fibonacci.lua
index 6dba1dd..0ff2f37 100644
--- a/tests/fibonacci.lua
+++ b/tests/fibonacci.lua
@@ -12,7 +12,7 @@
12 12
13-- Need to say it's 'local' so it can be an upvalue 13-- Need to say it's 'local' so it can be an upvalue
14-- 14--
15local lanes = require "lanes".configure{ nb_keepers =1, with_timers = false} 15local lanes = require "lanes".configure()
16 16
17local function WR(str) 17local function WR(str)
18 io.stderr:write( str.."\n" ) 18 io.stderr:write( str.."\n" )
@@ -27,7 +27,7 @@ local KNOWN= { [0]=0, 1,1,2,3,5,8,13,21,34,55,89,144 }
27set_debug_threadname = function ( ...) 27set_debug_threadname = function ( ...)
28end 28end
29 29
30 -- 30 --
31-- uint= fib( n_uint ) 31-- uint= fib( n_uint )
32-- 32--
33local function fib( n ) 33local function fib( n )
@@ -72,20 +72,20 @@ end
72-- 72--
73local right= 73local right=
74{ 74{
75 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711, 75 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711,
76 28657, 46368, 75025, 121393, 196418, 317811, 514229, 832040, 1346269, 2178309, 3524578, 5702887, 76 28657, 46368, 75025, 121393, 196418, 317811, 514229, 832040, 1346269, 2178309, 3524578, 5702887,
77 9227465, 14930352, 24157817, 39088169, 63245986, 102334155, 165580141, 267914296, 433494437, 77 9227465, 14930352, 24157817, 39088169, 63245986, 102334155, 165580141, 267914296, 433494437,
78 701408733, 1134903170, 1836311903, 2971215073, 4807526976, 7778742049, 12586269025, 20365011074, 78 701408733, 1134903170, 1836311903, 2971215073, 4807526976, 7778742049, 12586269025, 20365011074,
79 32951280099, 53316291173, 86267571272, 139583862445, 225851433717, 365435296162, 591286729879, 79 32951280099, 53316291173, 86267571272, 139583862445, 225851433717, 365435296162, 591286729879,
80 956722026041, 1548008755920, 2504730781961, 4052739537881, 6557470319842, 10610209857723, 80 956722026041, 1548008755920, 2504730781961, 4052739537881, 6557470319842, 10610209857723,
81 17167680177565, 27777890035288, 44945570212853, 72723460248141, 117669030460994, 190392490709135, 81 17167680177565, 27777890035288, 44945570212853, 72723460248141, 117669030460994, 190392490709135,
82 308061521170129, 498454011879264, 806515533049393, 1304969544928657, 2111485077978050, 82 308061521170129, 498454011879264, 806515533049393, 1304969544928657, 2111485077978050,
83 3416454622906707, 5527939700884757, 8944394323791464, 14472334024676220, 23416728348467684, 83 3416454622906707, 5527939700884757, 8944394323791464, 14472334024676220, 23416728348467684,
84 37889062373143900, 61305790721611580, 99194853094755490, 160500643816367070, 259695496911122560, 84 37889062373143900, 61305790721611580, 99194853094755490, 160500643816367070, 259695496911122560,
85 420196140727489660, 679891637638612200, 1100087778366101900, 1779979416004714000, 85 420196140727489660, 679891637638612200, 1100087778366101900, 1779979416004714000,
86 2880067194370816000, 4660046610375530000, 7540113804746346000, 12200160415121877000, 86 2880067194370816000, 4660046610375530000, 7540113804746346000, 12200160415121877000,
87 19740274219868226000, 31940434634990105000, 51680708854858334000, 83621143489848440000, 87 19740274219868226000, 31940434634990105000, 51680708854858334000, 83621143489848440000,
88 135301852344706780000, 218922995834555200000 88 135301852344706780000, 218922995834555200000
89} 89}
90assert( #right==99 ) 90assert( #right==99 )
91 91
diff --git a/tests/irayo_recursive.lua b/tests/irayo_recursive.lua
index 2f8b8a8..fe722a3 100644
--- a/tests/irayo_recursive.lua
+++ b/tests/irayo_recursive.lua
@@ -1,4 +1,4 @@
1local lanes = require "lanes".configure{ nb_keepers = 1, with_timers = false} 1local lanes = require "lanes".configure()
2-- 2--
3-- Bugs filed by irayo Jul-2008 3-- Bugs filed by irayo Jul-2008
4-- 4--
diff --git a/tests/keeper.lua b/tests/keeper.lua
index e758b54..d08dd98 100644
--- a/tests/keeper.lua
+++ b/tests/keeper.lua
@@ -3,20 +3,20 @@
3-- 3--
4-- Test program for Lua Lanes 4-- Test program for Lua Lanes
5-- 5--
6-- TODO: there is a random crash when nb_keepers > 1. Will have to investigate 6-- TODO: there is a random crash when nb_user_keepers > 1. Will have to investigate if it rears its ugly head again
7local lanes = require "lanes".configure{ with_timers = false, nb_keepers = 1, keepers_gc_threshold = 500} 7local lanes = require "lanes".configure{ nb_user_keepers = 3, keepers_gc_threshold = 500 }
8 8
9do 9do
10 print "Linda names test:" 10 print "Linda names test:"
11 local unnamedLinda = lanes.linda() 11 local unnamedLinda = lanes.linda(1)
12 local unnamedLinda2 = lanes.linda("") 12 local unnamedLinda2 = lanes.linda("", 2)
13 local veeeerrrryyyylooongNamedLinda= lanes.linda( "veeeerrrryyyylooongNamedLinda", 1) 13 local veeeerrrryyyylooongNamedLinda= lanes.linda( "veeeerrrryyyylooongNamedLinda", 3)
14 print(unnamedLinda, unnamedLinda2, veeeerrrryyyylooongNamedLinda) 14 print(unnamedLinda, unnamedLinda2, veeeerrrryyyylooongNamedLinda)
15 print "GC deadlock test start" 15 print "GC deadlock test start"
16 -- store a linda in another linda (-> in a keeper) 16 -- store a linda in another linda (-> in a keeper)
17 unnamedLinda:set("here", lanes.linda("temporary linda")) 17 unnamedLinda:set("here", lanes.linda("temporary linda", 0))
18 -- repeatedly add and remove stuff in the linda so that a GC happens during the keeper operation 18 -- repeatedly add and remove stuff in the linda so that a GC happens during the keeper operation
19 for i = 1, 1000 do 19 for i = 1, 100 do
20 for j = 1, 1000 do -- send 1000 tables 20 for j = 1, 1000 do -- send 1000 tables
21 -- print("send #" .. j) 21 -- print("send #" .. j)
22 unnamedLinda:send("here", {"a", "table", "with", "some", "stuff"}) 22 unnamedLinda:send("here", {"a", "table", "with", "some", "stuff"})
diff --git a/tests/nameof.lua b/tests/nameof.lua
index 5c4f1b1..58df3e2 100644
--- a/tests/nameof.lua
+++ b/tests/nameof.lua
@@ -1,4 +1,4 @@
1local lanes = require "lanes".configure{on_state_create = function() end} 1local lanes = require "lanes".configure{nb_user_keepers = 100, on_state_create = function() end}
2 2
3print("Name of table: ", lanes.nameof({})) 3print("Name of table: ", lanes.nameof({}))
4print("Name of string.sub: ", lanes.nameof(string.sub)) 4print("Name of string.sub: ", lanes.nameof(string.sub))
diff --git a/tests/nb_keepers.lua b/tests/nb_keepers.lua
new file mode 100644
index 0000000..575138c
--- /dev/null
+++ b/tests/nb_keepers.lua
@@ -0,0 +1,20 @@
1-- 2 keepers in addition to the one reserved for the timer linda
2local require_lanes_result_1, require_lanes_result_2 = require "lanes".configure{nb_user_keepers = 2}
3print("require_lanes_result:", require_lanes_result_1, require_lanes_result_2)
4local lanes = require_lanes_result_1
5
6local require_assert_result_1, require_assert_result_2 = require "assert" -- assert.fails()
7print("require_assert_result:", require_assert_result_1, require_assert_result_2)
8
9local createLinda = function(...)
10 return lanes.linda(...)
11end
12
13-- should succeed
14assert.failsnot(function() createLinda("one", 1) end)
15assert.failsnot(function() createLinda("two", 2) end)
16-- should fail
17assert.fails(function() createLinda("none") end)
18assert.fails(function() createLinda("zero", 0) end)
19assert.fails(function() createLinda("three", 3) end)
20print "TEST OK"
diff --git a/tests/parallel_os_calls.lua b/tests/parallel_os_calls.lua
index 7119272..596053c 100644
--- a/tests/parallel_os_calls.lua
+++ b/tests/parallel_os_calls.lua
@@ -1,4 +1,4 @@
1local lanes = require "lanes".configure{with_timers = false, nb_keepers = 1} 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(10, "null") print("finished_sleeping " .. os.date()) end)()