aboutsummaryrefslogtreecommitdiff
path: root/spec/outputs/5.1/test/try_catch_spec.lua
blob: 90e656b1ff9563dac58fb250d17c9e881310ae70 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
local _anon_func_0 = function(e, error)
	return error("wrap:" .. e:match("^.-:%d+:%s*(.*)$"))
end
return describe("try/catch", function()
	return it("catch and rethrow", function()
		local pcall = pcall
		local error = error
		local xpcall = xpcall
		local assert = assert
		local ok, success, err = pcall(function()
			return xpcall(function()
				return error("boom")
			end, function(e)
				local _, result = pcall(_anon_func_0, e, error)
				return result
			end)
		end)
		assert.same(ok, true)
		assert.same(success, false)
		return assert.is_true(err:match("wrap:boom") ~= nil)
	end)
end)