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