aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/nameof.lua28
1 files changed, 24 insertions, 4 deletions
diff --git a/tests/nameof.lua b/tests/nameof.lua
index 221c893..79d5760 100644
--- a/tests/nameof.lua
+++ b/tests/nameof.lua
@@ -1,5 +1,25 @@
1lanes = require "lanes".configure() 1local lanes = require "lanes".configure()
2 2
3print( lanes.nameof( {})) 3print("Name of table: ", lanes.nameof({}))
4print( lanes.nameof( string.sub)) 4print("Name of string.sub: ", lanes.nameof(string.sub))
5print( lanes.nameof( print)) 5print("Name of print: ", lanes.nameof(print))
6
7-- a standalone function without any dependency
8local body = function()
9 local n = 0
10 for i = 1, 1e30 do
11 n = n + 1
12 end
13end
14
15-- start the lane without any library
16local h = lanes.gen(nil, body)()
17lanes.sleep(0.1)
18print("Name of lane: ", lanes.nameof(h), "("..h.status..")")
19assert(h.status == "running")
20-- cancel the lane
21h:cancel("line", 1)
22lanes.sleep(0.1)
23print("Name of lane: ", lanes.nameof(h), "("..h.status..")")
24assert(h.status == "cancelled")
25print "TEST OK" \ No newline at end of file