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