1 local json
= require("json")
2 local lunit
= require("lunit")
3 local math
= require("math")
4 local testutil
= require("testutil")
6 local setmetatable
= setmetatable
9 _ENV
= lunit
.module("lunit-encoderfunc", 'seeall')
11 module("lunit-encoderfunc", lunit
.testcase
, package
.seeall
)
14 local function build_call(name
, parameters
)
15 return json
.util
.buildCall(name
, unpack(parameters
, parameters
.n
))
18 function test_param_counts()
19 local encoder
= json
.encode
.getEncoder()
20 assert(encoder(build_call('noparam', {})))
21 assert(encoder(build_call('oneparam', {1})))
22 assert(encoder(build_call('multiparam', {1,2})))
25 function test_output()
26 local encoder
= json
.encode
.getEncoder()
27 assert_equal('b64("hello")', encoder(build_call('b64', {'hello'})))
28 assert_equal('add(1,2)', encoder(build_call('add', {1,2})))
29 assert_equal('dood([b64("hello"),add(1,2)])',
30 encoder(build_call('dood', { {
31 build_call('b64', {'hello'}),
32 build_call('add', {1,2})