diff options
Diffstat (limited to 'spec/outputs/test/try_catch_spec.lua')
| -rw-r--r-- | spec/outputs/test/try_catch_spec.lua | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/spec/outputs/test/try_catch_spec.lua b/spec/outputs/test/try_catch_spec.lua index 2bcfc16..4183610 100644 --- a/spec/outputs/test/try_catch_spec.lua +++ b/spec/outputs/test/try_catch_spec.lua | |||
| @@ -1,14 +1,20 @@ | |||
| 1 | local _anon_func_0 = function(error) | ||
| 2 | return error("boom") | ||
| 3 | end | ||
| 4 | local _anon_func_1 = function(e, error) | ||
| 5 | return error("wrap:" .. e:match("^.-:%d+:%s*(.*)$")) | ||
| 6 | end | ||
| 1 | return describe("try/catch", function() | 7 | return describe("try/catch", function() |
| 2 | return it("catch and rethrow", function() | 8 | return it("catch and rethrow", function() |
| 9 | local pcall <const> = pcall | ||
| 10 | local error <const> = error | ||
| 11 | local xpcall <const> = xpcall | ||
| 12 | local assert <const> = assert | ||
| 3 | local ok, success, err = pcall(function() | 13 | local ok, success, err = pcall(function() |
| 4 | return xpcall(function() | 14 | return xpcall(_anon_func_0, function(e) |
| 5 | return error("boom") | 15 | local _, result = pcall(_anon_func_1, e, error) |
| 6 | end, function(e) | ||
| 7 | local _, result = pcall(function() | ||
| 8 | return error("wrap:" .. e:match("^.-:%d+:%s*(.*)$")) | ||
| 9 | end) | ||
| 10 | return result | 16 | return result |
| 11 | end) | 17 | end, error) |
| 12 | end) | 18 | end) |
| 13 | assert.same(ok, true) | 19 | assert.same(ok, true) |
| 14 | assert.same(success, false) | 20 | assert.same(success, false) |
