aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/func_is_string.lua31
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 @@
1local lanes = require "lanes" 1local lanes = require "lanes"
2lanes.configure() 2
3-- Lua 5.4 specific:
4if _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)
19end
20
3 21
4local options = {globals = { b = 666 }} 22local options = {globals = { b = 666 }}
5 23
6-- local gen1 = lanes.gen("*", "dofile('fibonacci.lua')") 24local gen1 = lanes.gen("*", "return true, dofile('fibonacci.lua')")
7local gen2 = lanes.gen(options, "return b") 25local gen2 = lanes.gen(options, "return b")
8 26
9-- fibLane = gen1() 27fibLane = gen1()
28lanes.sleep(0.1)
29print(fibLane, fibLane.status)
30local _status, _err = fibLane:join()
31print(_status, _err)
32
10retLane1, retLane2 = gen2(), gen2() 33retLane1, retLane2 = gen2(), gen2()
11-- fibLane:join()
12 34
13print( retLane1[1], retLane2[1]) 35print( retLane1[1], retLane2[1])
36print "TEST OK" \ No newline at end of file