diff options
Diffstat (limited to 'tests/track_lanes.lua')
-rw-r--r-- | tests/track_lanes.lua | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/tests/track_lanes.lua b/tests/track_lanes.lua index daaa94c..5ea9a4e 100644 --- a/tests/track_lanes.lua +++ b/tests/track_lanes.lua | |||
@@ -1,5 +1,9 @@ | |||
1 | local lanes = require "lanes" .configure{ with_timers = false, track_lanes = true} | 1 | local lanes = require "lanes" .configure{ with_timers = false, track_lanes = true} |
2 | local wait = lanes.sleep | 2 | |
3 | local SLEEP = function(...) | ||
4 | local k, v = lanes.sleep(...) | ||
5 | assert(k == nil and v == "timeout") | ||
6 | end | ||
3 | 7 | ||
4 | print "hello" | 8 | print "hello" |
5 | 9 | ||
@@ -43,7 +47,7 @@ g( "forever", 'indefinitely') | |||
43 | g( "two_seconds", 2) | 47 | g( "two_seconds", 2) |
44 | 48 | ||
45 | -- give a bit of time to reach the linda waiting call | 49 | -- give a bit of time to reach the linda waiting call |
46 | wait( 0.1) | 50 | SLEEP(0.1) |
47 | 51 | ||
48 | -- list the known lanes (should be living lanes) | 52 | -- list the known lanes (should be living lanes) |
49 | local threads = track( "============= START", 2) | 53 | local threads = track( "============= START", 2) |
@@ -51,7 +55,7 @@ local threads = track( "============= START", 2) | |||
51 | assert(threads[1].status == 'waiting' and threads[2].status == 'waiting') | 55 | assert(threads[1].status == 'waiting' and threads[2].status == 'waiting') |
52 | 56 | ||
53 | -- wait until "two_seconds has completed" | 57 | -- wait until "two_seconds has completed" |
54 | wait(2.1) | 58 | SLEEP(2.1) |
55 | 59 | ||
56 | local threads = track( "============= two_seconds dead", 2) | 60 | local threads = track( "============= two_seconds dead", 2) |
57 | -- two_seconds forever | 61 | -- two_seconds forever |
@@ -61,7 +65,7 @@ assert(threads[1].status == 'done' and threads[2].status == 'waiting') | |||
61 | g( "two_seconds", 2) | 65 | g( "two_seconds", 2) |
62 | 66 | ||
63 | -- give a bit of time to reach the linda waiting call | 67 | -- give a bit of time to reach the linda waiting call |
64 | wait( 0.1) | 68 | SLEEP( 0.1) |
65 | 69 | ||
66 | -- list the known lanes | 70 | -- list the known lanes |
67 | -- unless garbage collector cleaned it, we should have 3 lanes | 71 | -- unless garbage collector cleaned it, we should have 3 lanes |