aboutsummaryrefslogtreecommitdiff
path: root/tests/error.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tests/error.lua')
-rw-r--r--tests/error.lua47
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/error.lua b/tests/error.lua
new file mode 100644
index 0000000..673bcb5
--- /dev/null
+++ b/tests/error.lua
@@ -0,0 +1,47 @@
1--
2-- Error reporting
3--
4-- Note: this code is supposed to end in errors; not included in 'make test'
5--
6
7require "lanes"
8
9local function lane()
10
11 local subf= function() -- this so that we can see the call stack
12 --error "aa"
13 error({})
14 error(error)
15 end
16 local subf2= function()
17 subf()
18 end
19 subf2()
20end
21
22local function cleanup(err)
23end
24
25local lgen = lanes.gen("*", { --[[finalizer=cleanup]] }, lane)
26
27---
28io.stderr:write( "\n** Error catching **\n" )
29--
30local h= lgen()
31local _,err,stack= h:join() -- wait for the lane (no automatic error propagation)
32
33if err then
34 assert( type(stack)=="table" )
35 io.stderr:write( "Lane error: "..tostring(err).."\n" )
36
37 io.stderr:write( "\t", table.concat(stack,"\n\t"), "\n" );
38end
39
40---
41io.stderr:write( "\n** Error propagation **\n" )
42--
43local h2= lgen()
44local _= h2[0]
45assert(false) -- does NOT get here
46
47--never ends