aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lua/cjson/util.lua (renamed from lua/cjson-misc.lua)0
-rwxr-xr-xlua/json2lua.lua6
-rwxr-xr-xlua/lua2json.lua4
-rwxr-xr-xtests/bench.lua8
-rwxr-xr-xtests/test.lua30
5 files changed, 24 insertions, 24 deletions
diff --git a/lua/cjson-misc.lua b/lua/cjson/util.lua
index 2142464..2142464 100644
--- a/lua/cjson-misc.lua
+++ b/lua/cjson/util.lua
diff --git a/lua/json2lua.lua b/lua/json2lua.lua
index 050b89d..014416d 100755
--- a/lua/json2lua.lua
+++ b/lua/json2lua.lua
@@ -7,8 +7,8 @@
7-- ./json2lua.lua test.json 7-- ./json2lua.lua test.json
8 8
9local json = require "cjson" 9local json = require "cjson"
10local misc = require "cjson-misc" 10local util = require "cjson.util"
11 11
12local json_text = misc.file_load(arg[1]) 12local json_text = util.file_load(arg[1])
13local t = json.decode(json_text) 13local t = json.decode(json_text)
14print(misc.serialise_value(t)) 14print(util.serialise_value(t))
diff --git a/lua/lua2json.lua b/lua/lua2json.lua
index 2a9ddf9..aee8869 100755
--- a/lua/lua2json.lua
+++ b/lua/lua2json.lua
@@ -7,14 +7,14 @@
7-- ./lua2json.lua test.lua 7-- ./lua2json.lua test.lua
8 8
9local json = require "cjson" 9local json = require "cjson"
10local misc = require "cjson-misc" 10local util = require "cjson.util"
11 11
12local env = { 12local env = {
13 json = { null = json.null }, 13 json = { null = json.null },
14 null = json.null 14 null = json.null
15} 15}
16 16
17local t = misc.run_script("data = " .. misc.file_load(arg[1]), env) 17local t = util.run_script("data = " .. util.file_load(arg[1]), env)
18print(json.encode(t.data)) 18print(json.encode(t.data))
19 19
20-- vi:ai et sw=4 ts=4: 20-- vi:ai et sw=4 ts=4:
diff --git a/tests/bench.lua b/tests/bench.lua
index 0709209..0299ff2 100755
--- a/tests/bench.lua
+++ b/tests/bench.lua
@@ -10,7 +10,7 @@ local json_module = os.getenv("JSON_MODULE") or "cjson"
10 10
11require "socket" 11require "socket"
12local json = require(json_module) 12local json = require(json_module)
13local misc = require "cjson-misc" 13local util = require "cjson.util"
14 14
15local function find_func(mod, funcnames) 15local function find_func(mod, funcnames)
16 for _, v in ipairs(funcnames) do 16 for _, v in ipairs(funcnames) do
@@ -68,7 +68,7 @@ function benchmark(tests, seconds, rep)
68end 68end
69 69
70function bench_file(filename) 70function bench_file(filename)
71 local data_json = misc.file_load(filename) 71 local data_json = util.file_load(filename)
72 local data_obj = json_decode(data_json) 72 local data_obj = json_decode(data_json)
73 73
74 local function test_encode() 74 local function test_encode()
@@ -86,9 +86,9 @@ function bench_file(filename)
86end 86end
87 87
88-- Optionally load any custom configuration required for this module 88-- Optionally load any custom configuration required for this module
89local success, data = pcall(misc.file_load, string.format("bench-%s.lua", json_module)) 89local success, data = pcall(util.file_load, string.format("bench-%s.lua", json_module))
90if success then 90if success then
91 misc.run_script(data, _G) 91 util.run_script(data, _G)
92 configure(json) 92 configure(json)
93end 93end
94 94
diff --git a/tests/test.lua b/tests/test.lua
index c860878..0434a38 100755
--- a/tests/test.lua
+++ b/tests/test.lua
@@ -7,7 +7,7 @@
7-- Note: The output of this script is easier to read with "less -S" 7-- Note: The output of this script is easier to read with "less -S"
8 8
9local json = require "cjson" 9local json = require "cjson"
10local misc = require "cjson-misc" 10local util = require "cjson.util"
11 11
12local function gen_ascii() 12local function gen_ascii()
13 local chars = {} 13 local chars = {}
@@ -48,16 +48,16 @@ local function gen_utf16_escaped()
48end 48end
49 49
50function test_decode_cycle(filename) 50function test_decode_cycle(filename)
51 local obj1 = json.decode(file_load(filename)) 51 local obj1 = json.decode(util.file_load(filename))
52 local obj2 = json.decode(json.encode(obj1)) 52 local obj2 = json.decode(json.encode(obj1))
53 return misc.compare_values(obj1, obj2) 53 return util.compare_values(obj1, obj2)
54end 54end
55 55
56local Inf = math.huge; 56local Inf = math.huge;
57local NaN = math.huge * 0; 57local NaN = math.huge * 0;
58local octets_raw = gen_ascii() 58local octets_raw = gen_ascii()
59local octets_escaped = misc.file_load("octets-escaped.dat") 59local octets_escaped = util.file_load("octets-escaped.dat")
60local utf8_loaded, utf8_raw = pcall(misc.file_load, "utf8.dat") 60local utf8_loaded, utf8_raw = pcall(util.file_load, "utf8.dat")
61if not utf8_loaded then 61if not utf8_loaded then
62 utf8_raw = "Failed to load utf8.dat" 62 utf8_raw = "Failed to load utf8.dat"
63end 63end
@@ -224,23 +224,23 @@ local locale_tests = {
224 224
225print(string.format("Testing Lua CJSON version %s\n", json.version)) 225print(string.format("Testing Lua CJSON version %s\n", json.version))
226 226
227misc.run_test_group("decode simple value", decode_simple_tests) 227util.run_test_group("decode simple value", decode_simple_tests)
228misc.run_test_group("encode simple value", encode_simple_tests) 228util.run_test_group("encode simple value", encode_simple_tests)
229misc.run_test_group("decode numeric", decode_numeric_tests) 229util.run_test_group("decode numeric", decode_numeric_tests)
230misc.run_test_group("encode table", encode_table_tests) 230util.run_test_group("encode table", encode_table_tests)
231misc.run_test_group("decode error", decode_error_tests) 231util.run_test_group("decode error", decode_error_tests)
232misc.run_test_group("encode error", encode_error_tests) 232util.run_test_group("encode error", encode_error_tests)
233misc.run_test_group("escape", escape_tests) 233util.run_test_group("escape", escape_tests)
234misc.run_test_group("locale", locale_tests) 234util.run_test_group("locale", locale_tests)
235 235
236json.refuse_invalid_numbers(false) 236json.refuse_invalid_numbers(false)
237json.encode_max_depth(20) 237json.encode_max_depth(20)
238for i = 1, #arg do 238for i = 1, #arg do
239 misc.run_test("decode cycle " .. arg[i], test_decode_cycle, { arg[i] }, 239 util.run_test("decode cycle " .. arg[i], test_decode_cycle, { arg[i] },
240 true, { true }) 240 true, { true })
241end 241end
242 242
243local pass, total = misc.run_test_summary() 243local pass, total = util.run_test_summary()
244 244
245if pass == total then 245if pass == total then
246 print("==> Summary: all tests succeeded") 246 print("==> Summary: all tests succeeded")