From 73d33f25760d4d4ffb7fa8acf6a67d0f7e19fec7 Mon Sep 17 00:00:00 2001 From: Mark Pulford Date: Fri, 13 Jan 2012 07:17:48 +1030 Subject: Rename "cjson-misc" module to "cjson.util" --- tests/bench.lua | 8 ++++---- tests/test.lua | 30 +++++++++++++++--------------- 2 files changed, 19 insertions(+), 19 deletions(-) (limited to 'tests') 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" require "socket" local json = require(json_module) -local misc = require "cjson-misc" +local util = require "cjson.util" local function find_func(mod, funcnames) for _, v in ipairs(funcnames) do @@ -68,7 +68,7 @@ function benchmark(tests, seconds, rep) end function bench_file(filename) - local data_json = misc.file_load(filename) + local data_json = util.file_load(filename) local data_obj = json_decode(data_json) local function test_encode() @@ -86,9 +86,9 @@ function bench_file(filename) end -- Optionally load any custom configuration required for this module -local success, data = pcall(misc.file_load, string.format("bench-%s.lua", json_module)) +local success, data = pcall(util.file_load, string.format("bench-%s.lua", json_module)) if success then - misc.run_script(data, _G) + util.run_script(data, _G) configure(json) end 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 @@ -- Note: The output of this script is easier to read with "less -S" local json = require "cjson" -local misc = require "cjson-misc" +local util = require "cjson.util" local function gen_ascii() local chars = {} @@ -48,16 +48,16 @@ local function gen_utf16_escaped() end function test_decode_cycle(filename) - local obj1 = json.decode(file_load(filename)) + local obj1 = json.decode(util.file_load(filename)) local obj2 = json.decode(json.encode(obj1)) - return misc.compare_values(obj1, obj2) + return util.compare_values(obj1, obj2) end local Inf = math.huge; local NaN = math.huge * 0; local octets_raw = gen_ascii() -local octets_escaped = misc.file_load("octets-escaped.dat") -local utf8_loaded, utf8_raw = pcall(misc.file_load, "utf8.dat") +local octets_escaped = util.file_load("octets-escaped.dat") +local utf8_loaded, utf8_raw = pcall(util.file_load, "utf8.dat") if not utf8_loaded then utf8_raw = "Failed to load utf8.dat" end @@ -224,23 +224,23 @@ local locale_tests = { print(string.format("Testing Lua CJSON version %s\n", json.version)) -misc.run_test_group("decode simple value", decode_simple_tests) -misc.run_test_group("encode simple value", encode_simple_tests) -misc.run_test_group("decode numeric", decode_numeric_tests) -misc.run_test_group("encode table", encode_table_tests) -misc.run_test_group("decode error", decode_error_tests) -misc.run_test_group("encode error", encode_error_tests) -misc.run_test_group("escape", escape_tests) -misc.run_test_group("locale", locale_tests) +util.run_test_group("decode simple value", decode_simple_tests) +util.run_test_group("encode simple value", encode_simple_tests) +util.run_test_group("decode numeric", decode_numeric_tests) +util.run_test_group("encode table", encode_table_tests) +util.run_test_group("decode error", decode_error_tests) +util.run_test_group("encode error", encode_error_tests) +util.run_test_group("escape", escape_tests) +util.run_test_group("locale", locale_tests) json.refuse_invalid_numbers(false) json.encode_max_depth(20) for i = 1, #arg do - misc.run_test("decode cycle " .. arg[i], test_decode_cycle, { arg[i] }, + util.run_test("decode cycle " .. arg[i], test_decode_cycle, { arg[i] }, true, { true }) end -local pass, total = misc.run_test_summary() +local pass, total = util.run_test_summary() if pass == total then print("==> Summary: all tests succeeded") -- cgit v1.2.3-55-g6feb