Skip to content
Snippets Groups Projects
Commit 9112af62 authored by Roman Tsisyk's avatar Roman Tsisyk
Browse files

Fix #754: improve compatibility with lua-cjson

parent 8f866b31
No related branches found
No related tags found
No related merge requests found
TAP version 13
# json
1..8
1..9
# unsigned
1..56
ok - encode/decode for 0
......@@ -184,4 +184,10 @@ ok - table
ok - udata hook priority
# ucdata: end
ok - ucdata
# misc
1..2
ok - .NULL is cdata
ok - .NULL == nil
# misc: end
ok - misc
# json: end
......@@ -14,9 +14,15 @@ local function is_array(s)
return string.sub(s, 1, 1) == "["
end
local function test_misc(test, s)
test:plan(2)
test:iscdata(s.NULL, 'void *', '.NULL is cdata')
test:ok(s.NULL == nil, '.NULL == nil')
end
tap.test("json", function(test)
local serializer = require('json')
test:plan(8)
test:plan(9)
test:test("unsigned", common.test_unsigned, serializer)
test:test("signed", common.test_signed, serializer)
test:test("double", common.test_double, serializer)
......@@ -25,4 +31,5 @@ tap.test("json", function(test)
test:test("nil", common.test_nil, serializer)
test:test("table", common.test_table, serializer, is_array, is_map)
test:test("ucdata", common.test_ucdata, serializer)
test:test("misc", test_misc, serializer)
end)
......@@ -1037,6 +1037,8 @@ luaopen_json(lua_State *L)
json_create_tokens();
luaL_json_default = luaL_newserializer(L, jsonlib);
luaL_register_module(L, "json", NULL);
luaL_pushnull(L);
lua_setfield(L, -2, "null"); /* compatibility with cjson */
return 1;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment