diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/func_is_string.lua | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/tests/func_is_string.lua b/tests/func_is_string.lua index d7cf0b2..a14c460 100644 --- a/tests/func_is_string.lua +++ b/tests/func_is_string.lua | |||
@@ -1,13 +1,36 @@ | |||
1 | local lanes = require "lanes" | 1 | local lanes = require "lanes" |
2 | lanes.configure() | 2 | |
3 | -- Lua 5.4 specific: | ||
4 | if _VERSION >= "Lua 5.4" then | ||
5 | -- go through a string so that the script we are in doesn't trigger a parse error with older Lua | ||
6 | local res = assert(load [[ | ||
7 | local lanes = require 'lanes' | ||
8 | local r | ||
9 | do | ||
10 | local h <close> = lanes.gen('*', lanes.sleep)(0.5) | ||
11 | r = h | ||
12 | end -- h is closed here | ||
13 | return r.status | ||
14 | ]])() | ||
15 | -- when the do...end block is exited, the to-be-closed variable h is closed, which internally calls h:join() | ||
16 | -- therefore the status of the lane should be "done" | ||
17 | assert(res == "done") | ||
18 | print("close result:", res) | ||
19 | end | ||
20 | |||
3 | 21 | ||
4 | local options = {globals = { b = 666 }} | 22 | local options = {globals = { b = 666 }} |
5 | 23 | ||
6 | -- local gen1 = lanes.gen("*", "dofile('fibonacci.lua')") | 24 | local gen1 = lanes.gen("*", "return true, dofile('fibonacci.lua')") |
7 | local gen2 = lanes.gen(options, "return b") | 25 | local gen2 = lanes.gen(options, "return b") |
8 | 26 | ||
9 | -- fibLane = gen1() | 27 | fibLane = gen1() |
28 | lanes.sleep(0.1) | ||
29 | print(fibLane, fibLane.status) | ||
30 | local _status, _err = fibLane:join() | ||
31 | print(_status, _err) | ||
32 | |||
10 | retLane1, retLane2 = gen2(), gen2() | 33 | retLane1, retLane2 = gen2(), gen2() |
11 | -- fibLane:join() | ||
12 | 34 | ||
13 | print( retLane1[1], retLane2[1]) | 35 | print( retLane1[1], retLane2[1]) |
36 | print "TEST OK" \ No newline at end of file | ||