aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMark Pulford <mark@kyne.com.au>2012-01-13 07:17:48 +1030
committerMark Pulford <mark@kyne.com.au>2012-03-04 18:54:34 +1030
commit73d33f25760d4d4ffb7fa8acf6a67d0f7e19fec7 (patch)
tree29e1bf0e1d0fb892eb0bdc6959f61da4b6cb639a /tests
parent5fb9fe1c67a070d1e83497c44b7b7364da9f1975 (diff)
downloadlua-cjson-73d33f25760d4d4ffb7fa8acf6a67d0f7e19fec7.tar.gz
lua-cjson-73d33f25760d4d4ffb7fa8acf6a67d0f7e19fec7.tar.bz2
lua-cjson-73d33f25760d4d4ffb7fa8acf6a67d0f7e19fec7.zip
Rename "cjson-misc" module to "cjson.util"
Diffstat (limited to 'tests')
-rwxr-xr-xtests/bench.lua8
-rwxr-xr-xtests/test.lua30
2 files changed, 19 insertions, 19 deletions
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")