diff options
| -rw-r--r-- | docs/index.html | 2 | ||||
| -rw-r--r-- | tests/timer.lua | 12 |
2 files changed, 10 insertions, 4 deletions
diff --git a/docs/index.html b/docs/index.html index 9e28f76..d857579 100644 --- a/docs/index.html +++ b/docs/index.html | |||
| @@ -1747,7 +1747,7 @@ | |||
| 1747 | <p></p> | 1747 | <p></p> |
| 1748 | 1748 | ||
| 1749 | <table border="1" bgcolor="#E0E0FF" cellpadding="10" style="width:50%"><tr><td><pre> | 1749 | <table border="1" bgcolor="#E0E0FF" cellpadding="10" style="width:50%"><tr><td><pre> |
| 1750 | {[{linda, slot, when, period}[,...]]} = lanes.timers() | 1750 | {[{linda, slot, {when [, period]}}[,...]]} = lanes.timers() |
| 1751 | </pre></td></tr></table> | 1751 | </pre></td></tr></table> |
| 1752 | 1752 | ||
| 1753 | <p> | 1753 | <p> |
diff --git a/tests/timer.lua b/tests/timer.lua index ac8b385..80a302d 100644 --- a/tests/timer.lua +++ b/tests/timer.lua | |||
| @@ -79,10 +79,16 @@ assert( caught[T2] ) | |||
| 79 | 79 | ||
| 80 | 80 | ||
| 81 | PRINT( "\n*** Listing timers ***\n" ) | 81 | PRINT( "\n*** Listing timers ***\n" ) |
| 82 | local r = lanes.timers() -- list of {linda, key, {}} | 82 | local r = lanes.timers() -- list of {linda, key, {when [, period]}} |
| 83 | for _,t in ipairs( r) do | 83 | for _,t in ipairs( r) do |
| 84 | local linda, key, timer = t[1], t[2], t[3] | 84 | local linda, key, timer_data = t[1], t[2], t[3] |
| 85 | print( tostring( linda), key, timer[1], timer[2]) | 85 | -- verify the structure: 3 elements, third is a nested table (not a flat 4-element entry) |
| 86 | assert(t[4] == nil, "timer entry must have exactly 3 elements, not 4 (flat structure)") | ||
| 87 | assert(type(linda) == "userdata", "timer entry [1] must be a linda userdata") | ||
| 88 | assert(type(timer_data) == "table", "timer entry [3] must be a table {when [, period]}, not a flat value") | ||
| 89 | assert(type(timer_data[1]) == "number", "timer_data[1] (when) must be a number") | ||
| 90 | assert(timer_data[2] == nil or type(timer_data[2]) == "number", "timer_data[2] (period) must be a number or nil") | ||
| 91 | print( tostring( linda), key, timer_data[1], timer_data[2]) | ||
| 86 | end | 92 | end |
| 87 | 93 | ||
| 88 | 94 | ||
