diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/nameof.lua | 28 |
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 @@ | |||
1 | lanes = require "lanes".configure() | 1 | local lanes = require "lanes".configure() |
2 | 2 | ||
3 | print( lanes.nameof( {})) | 3 | print("Name of table: ", lanes.nameof({})) |
4 | print( lanes.nameof( string.sub)) | 4 | print("Name of string.sub: ", lanes.nameof(string.sub)) |
5 | print( lanes.nameof( print)) | 5 | print("Name of print: ", lanes.nameof(print)) |
6 | |||
7 | -- a standalone function without any dependency | ||
8 | local body = function() | ||
9 | local n = 0 | ||
10 | for i = 1, 1e30 do | ||
11 | n = n + 1 | ||
12 | end | ||
13 | end | ||
14 | |||
15 | -- start the lane without any library | ||
16 | local h = lanes.gen(nil, body)() | ||
17 | lanes.sleep(0.1) | ||
18 | print("Name of lane: ", lanes.nameof(h), "("..h.status..")") | ||
19 | assert(h.status == "running") | ||
20 | -- cancel the lane | ||
21 | h:cancel("line", 1) | ||
22 | lanes.sleep(0.1) | ||
23 | print("Name of lane: ", lanes.nameof(h), "("..h.status..")") | ||
24 | assert(h.status == "cancelled") | ||
25 | print "TEST OK" \ No newline at end of file | ||