codecov: apply report generation automatically
[luajson.git] / tests / testutil.lua
blob3667a03e097f9f0adf75acae24ba7bc480278018
1 local pcall, error = pcall, error
3 local lunit = require("lunit")
4 local assert_error = lunit.assert_error
6 -- Allow module to alter decoder
7 local function setDecoder(d)
8 _G.decode = d
9 end
11 local function buildPatchedDecoder(f, newDecoder)
12 return function()
13 setDecoder(newDecoder)
14 f()
15 end
16 end
17 local function buildFailedPatchedDecoder(f, newDecoder)
18 return function()
19 setDecoder(newDecoder)
20 assert_error(f)
21 end
22 end
24 return {
25 buildPatchedDecoder = buildPatchedDecoder,
26 buildFailedPatchedDecoder = buildFailedPatchedDecoder