diff options
author | Mark Pulford <mark@kyne.com.au> | 2012-01-13 07:17:48 +1030 |
---|---|---|
committer | Mark Pulford <mark@kyne.com.au> | 2012-03-04 18:54:34 +1030 |
commit | 73d33f25760d4d4ffb7fa8acf6a67d0f7e19fec7 (patch) | |
tree | 29e1bf0e1d0fb892eb0bdc6959f61da4b6cb639a /tests | |
parent | 5fb9fe1c67a070d1e83497c44b7b7364da9f1975 (diff) | |
download | lua-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-x | tests/bench.lua | 8 | ||||
-rwxr-xr-x | tests/test.lua | 30 |
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 | ||
11 | require "socket" | 11 | require "socket" |
12 | local json = require(json_module) | 12 | local json = require(json_module) |
13 | local misc = require "cjson-misc" | 13 | local util = require "cjson.util" |
14 | 14 | ||
15 | local function find_func(mod, funcnames) | 15 | local 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) | |||
68 | end | 68 | end |
69 | 69 | ||
70 | function bench_file(filename) | 70 | function 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) | |||
86 | end | 86 | end |
87 | 87 | ||
88 | -- Optionally load any custom configuration required for this module | 88 | -- Optionally load any custom configuration required for this module |
89 | local success, data = pcall(misc.file_load, string.format("bench-%s.lua", json_module)) | 89 | local success, data = pcall(util.file_load, string.format("bench-%s.lua", json_module)) |
90 | if success then | 90 | if success then |
91 | misc.run_script(data, _G) | 91 | util.run_script(data, _G) |
92 | configure(json) | 92 | configure(json) |
93 | end | 93 | end |
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 | ||
9 | local json = require "cjson" | 9 | local json = require "cjson" |
10 | local misc = require "cjson-misc" | 10 | local util = require "cjson.util" |
11 | 11 | ||
12 | local function gen_ascii() | 12 | local function gen_ascii() |
13 | local chars = {} | 13 | local chars = {} |
@@ -48,16 +48,16 @@ local function gen_utf16_escaped() | |||
48 | end | 48 | end |
49 | 49 | ||
50 | function test_decode_cycle(filename) | 50 | function 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) |
54 | end | 54 | end |
55 | 55 | ||
56 | local Inf = math.huge; | 56 | local Inf = math.huge; |
57 | local NaN = math.huge * 0; | 57 | local NaN = math.huge * 0; |
58 | local octets_raw = gen_ascii() | 58 | local octets_raw = gen_ascii() |
59 | local octets_escaped = misc.file_load("octets-escaped.dat") | 59 | local octets_escaped = util.file_load("octets-escaped.dat") |
60 | local utf8_loaded, utf8_raw = pcall(misc.file_load, "utf8.dat") | 60 | local utf8_loaded, utf8_raw = pcall(util.file_load, "utf8.dat") |
61 | if not utf8_loaded then | 61 | if not utf8_loaded then |
62 | utf8_raw = "Failed to load utf8.dat" | 62 | utf8_raw = "Failed to load utf8.dat" |
63 | end | 63 | end |
@@ -224,23 +224,23 @@ local locale_tests = { | |||
224 | 224 | ||
225 | print(string.format("Testing Lua CJSON version %s\n", json.version)) | 225 | print(string.format("Testing Lua CJSON version %s\n", json.version)) |
226 | 226 | ||
227 | misc.run_test_group("decode simple value", decode_simple_tests) | 227 | util.run_test_group("decode simple value", decode_simple_tests) |
228 | misc.run_test_group("encode simple value", encode_simple_tests) | 228 | util.run_test_group("encode simple value", encode_simple_tests) |
229 | misc.run_test_group("decode numeric", decode_numeric_tests) | 229 | util.run_test_group("decode numeric", decode_numeric_tests) |
230 | misc.run_test_group("encode table", encode_table_tests) | 230 | util.run_test_group("encode table", encode_table_tests) |
231 | misc.run_test_group("decode error", decode_error_tests) | 231 | util.run_test_group("decode error", decode_error_tests) |
232 | misc.run_test_group("encode error", encode_error_tests) | 232 | util.run_test_group("encode error", encode_error_tests) |
233 | misc.run_test_group("escape", escape_tests) | 233 | util.run_test_group("escape", escape_tests) |
234 | misc.run_test_group("locale", locale_tests) | 234 | util.run_test_group("locale", locale_tests) |
235 | 235 | ||
236 | json.refuse_invalid_numbers(false) | 236 | json.refuse_invalid_numbers(false) |
237 | json.encode_max_depth(20) | 237 | json.encode_max_depth(20) |
238 | for i = 1, #arg do | 238 | for 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 }) |
241 | end | 241 | end |
242 | 242 | ||
243 | local pass, total = misc.run_test_summary() | 243 | local pass, total = util.run_test_summary() |
244 | 244 | ||
245 | if pass == total then | 245 | if pass == total then |
246 | print("==> Summary: all tests succeeded") | 246 | print("==> Summary: all tests succeeded") |