aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/error.lua23
-rw-r--r--tests/linda_perf.lua2
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
7local lanes = require "lanes".configure() 7local lanes = require "lanes".configure{ with_timers = false}
8
9local function lane()
10 8
9local 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---
28io.stderr:write( "\n** Error catching **\n" ) 28io.stderr:write( "\n** Error catching **\n" )
29-- 29--
30local h= lgen() 30
31local error_reporting_mode = "extended"
32local h= lgen( error_reporting_mode)
31local _,err,stack= h:join() -- wait for the lane (no automatic error propagation) 33local _,err,stack= h:join() -- wait for the lane (no automatic error propagation)
32 34
33if err then 35if 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
38end 49end
39 50
40--- 51---
41io.stderr:write( "\n** Error propagation **\n" ) 52io.stderr:write( "\n** Error propagation **\n" )
42-- 53--
43local h2= lgen() 54local h2= lgen( error_reporting_mode)
44local _= h2[0] 55local _= h2[0]
45assert(false) -- does NOT get here 56assert(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 @@
1local lanes = require "lanes" 1local lanes = require "lanes"
2lanes.configure() 2lanes.configure{ with_timers = false}
3 3
4-- Lua 5.1/5.2 compatibility 4-- Lua 5.1/5.2 compatibility
5local table_unpack = unpack or table.unpack 5local table_unpack = unpack or table.unpack