diff options
-rw-r--r-- | tests/error.lua | 23 | ||||
-rw-r--r-- | tests/linda_perf.lua | 2 |
2 files changed, 18 insertions, 7 deletions
diff --git a/tests/error.lua b/tests/error.lua index 91015d8..91ccebc 100644 --- a/tests/error.lua +++ b/tests/error.lua | |||
@@ -4,10 +4,10 @@ | |||
4 | -- Note: this code is supposed to end in errors; not included in 'make test' | 4 | -- Note: this code is supposed to end in errors; not included in 'make test' |
5 | -- | 5 | -- |
6 | 6 | ||
7 | local lanes = require "lanes".configure() | 7 | local lanes = require "lanes".configure{ with_timers = false} |
8 | |||
9 | local function lane() | ||
10 | 8 | ||
9 | local function lane( mode_) | ||
10 | set_error_reporting( mode_) | ||
11 | local subf= function() -- this so that we can see the call stack | 11 | local subf= function() -- this so that we can see the call stack |
12 | error "aa" | 12 | error "aa" |
13 | --error({}) | 13 | --error({}) |
@@ -27,20 +27,31 @@ local lgen = lanes.gen("*", { --[[finalizer=cleanup]] }, lane) | |||
27 | --- | 27 | --- |
28 | io.stderr:write( "\n** Error catching **\n" ) | 28 | io.stderr:write( "\n** Error catching **\n" ) |
29 | -- | 29 | -- |
30 | local h= lgen() | 30 | |
31 | local error_reporting_mode = "extended" | ||
32 | local h= lgen( error_reporting_mode) | ||
31 | local _,err,stack= h:join() -- wait for the lane (no automatic error propagation) | 33 | local _,err,stack= h:join() -- wait for the lane (no automatic error propagation) |
32 | 34 | ||
33 | if err then | 35 | if err then |
34 | assert( type(stack)=="table" ) -- only true if lanes was compiled with ERROR_FULL_STACK == 1 | 36 | assert( type(stack)=="table" ) -- only true if lanes was compiled with ERROR_FULL_STACK == 1 |
35 | io.stderr:write( "Lane error: "..tostring(err).."\n" ) | 37 | io.stderr:write( "Lane error: "..tostring(err).."\n" ) |
36 | 38 | ||
37 | io.stderr:write( "\t", table.concat(stack,"\n\t"), "\n" ); | 39 | if error_reporting_mode == "basic" then -- each stack line is a string in basic mode |
40 | io.stderr:write( "\t", table.concat(stack,"\n\t"), "\n" ); | ||
41 | else -- each stack line is a table in extended mode | ||
42 | for line, details in pairs( stack) do | ||
43 | io.stderr:write( "\t", tostring( line), "\n" ); | ||
44 | for detail, value in pairs( details) do | ||
45 | io.stderr:write( "\t\t", tostring( detail), ":", tostring( value), "\n") | ||
46 | end | ||
47 | end | ||
48 | end | ||
38 | end | 49 | end |
39 | 50 | ||
40 | --- | 51 | --- |
41 | io.stderr:write( "\n** Error propagation **\n" ) | 52 | io.stderr:write( "\n** Error propagation **\n" ) |
42 | -- | 53 | -- |
43 | local h2= lgen() | 54 | local h2= lgen( error_reporting_mode) |
44 | local _= h2[0] | 55 | local _= h2[0] |
45 | assert(false) -- does NOT get here | 56 | assert(false) -- does NOT get here |
46 | 57 | ||
diff --git a/tests/linda_perf.lua b/tests/linda_perf.lua index 1a44d07..fa2d633 100644 --- a/tests/linda_perf.lua +++ b/tests/linda_perf.lua | |||
@@ -1,5 +1,5 @@ | |||
1 | local lanes = require "lanes" | 1 | local lanes = require "lanes" |
2 | lanes.configure() | 2 | lanes.configure{ with_timers = false} |
3 | 3 | ||
4 | -- Lua 5.1/5.2 compatibility | 4 | -- Lua 5.1/5.2 compatibility |
5 | local table_unpack = unpack or table.unpack | 5 | local table_unpack = unpack or table.unpack |