diff --git a/library/lua/test_util/mock.lua b/library/lua/test_util/mock.lua index dde1b1ee2..10bdc64cf 100644 --- a/library/lua/test_util/mock.lua +++ b/library/lua/test_util/mock.lua @@ -34,7 +34,7 @@ function mock.patch(...) table.insert(patches, p) end - dfhack.with_finalize( + return dfhack.with_finalize( function() for _, p in ipairs(patches) do p.table[p.key] = p.old_value @@ -44,7 +44,7 @@ function mock.patch(...) for _, p in ipairs(patches) do p.table[p.key] = p.new_value end - callback() + return callback() end ) end diff --git a/test/library/test_util/mock.lua b/test/library/test_util/mock.lua index 40f80b165..86b621b14 100644 --- a/test/library/test_util/mock.lua +++ b/test/library/test_util/mock.lua @@ -90,3 +90,11 @@ function test.patch_complex_key() end) expect.eq(t[key], 'value') end + +function test.patch_callback_return_value() + local a, b = mock.patch({}, 'k', 'v', function() + return 3, 4 + end) + expect.eq(a, 3) + expect.eq(b, 4) +end