decoder: fixes compatibility with lpeg 0.12 by closing off 0-length captures in loops
[luajson.git] / tests / testutil.lua
blob66d8595a2158764a6332a1bf38d027c963e2d761
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 decode = d
9 end
10 module("testutil", package.seeall)
11 function buildPatchedDecoder(f, newDecoder)
12 return function()
13 setDecoder(newDecoder)
14 f()
15 end
16 end
17 function buildFailedPatchedDecoder(f, newDecoder)
18 return function()
19 setDecoder(newDecoder)
20 assert_error(f)
21 end
22 end