diff options
author | Alexey Melnichuk <mimir@newmail.ru> | 2014-06-23 09:40:01 +0500 |
---|---|---|
committer | Alexey Melnichuk <mimir@newmail.ru> | 2014-06-23 09:40:01 +0500 |
commit | f0a6754cd15912de529b9662e3e08bfaadd6bf1e (patch) | |
tree | 49da84a4d154dfd4771093cfd9aaacc47036ca78 /test/test_threads_ex_opt.lua | |
parent | ed9ed9a1c794c0d49f83cb00a557ae6085bf47e4 (diff) | |
download | lua-llthreads2-f0a6754cd15912de529b9662e3e08bfaadd6bf1e.tar.gz lua-llthreads2-f0a6754cd15912de529b9662e3e08bfaadd6bf1e.tar.bz2 lua-llthreads2-f0a6754cd15912de529b9662e3e08bfaadd6bf1e.zip |
Add. `llthreads2.ex` module.
Diffstat (limited to 'test/test_threads_ex_opt.lua')
-rw-r--r-- | test/test_threads_ex_opt.lua | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/test/test_threads_ex_opt.lua b/test/test_threads_ex_opt.lua new file mode 100644 index 0000000..2e1d715 --- /dev/null +++ b/test/test_threads_ex_opt.lua | |||
@@ -0,0 +1,31 @@ | |||
1 | local thread_code = function(...) | ||
2 | local function assert_equal(name, a, b, ...) | ||
3 | if a == b then return b, ... end | ||
4 | print(name .. " Fail! Expected `" .. tostring(a) .. "` got `" .. tostring(b) .. "`") | ||
5 | os.exit(1) | ||
6 | end | ||
7 | |||
8 | local a,b,c,d,e,f = ... | ||
9 | assert_equal("1:", 1 , a ) | ||
10 | assert_equal("2:", nil , b ) | ||
11 | assert_equal("3:", 'hello' , c ) | ||
12 | assert_equal("4:", nil , d ) | ||
13 | assert_equal("5:", 2 , e ) | ||
14 | assert_equal("6:", nil , f ) | ||
15 | assert_equal("#:", 6 , select("#", ...)) | ||
16 | end | ||
17 | |||
18 | local llthreads = require"llthreads.ex" | ||
19 | |||
20 | -- pass `prelude` function that change thread arguments | ||
21 | local thread = llthreads.new({thread_code, prelude = function(...) | ||
22 | return 1, nil, 'hello', ... | ||
23 | end}, nil, 2, nil) | ||
24 | |||
25 | local a = assert(thread:start()) | ||
26 | |||
27 | assert(thread:join()) | ||
28 | |||
29 | assert(a == thread) | ||
30 | |||
31 | print("done!") \ No newline at end of file | ||