diff options
author | Mark Pulford <mark@kyne.com.au> | 2012-01-19 23:36:16 +1030 |
---|---|---|
committer | Mark Pulford <mark@kyne.com.au> | 2012-03-04 18:54:35 +1030 |
commit | 31bf122c1d1d9e3812b9ef2555d537f509ae3f05 (patch) | |
tree | b382fa3fecb784598ff8b0c64c1360c3bc24db2a /tests | |
parent | a0961903e3ff846a2bde6faa6d390435cd9937ef (diff) | |
download | lua-cjson-31bf122c1d1d9e3812b9ef2555d537f509ae3f05.tar.gz lua-cjson-31bf122c1d1d9e3812b9ef2555d537f509ae3f05.tar.bz2 lua-cjson-31bf122c1d1d9e3812b9ef2555d537f509ae3f05.zip |
Simplify string.format() calls
Simply string.format() calls with OO method notation.
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/bench.lua | 4 | ||||
-rwxr-xr-x | tests/test.lua | 6 |
2 files changed, 5 insertions, 5 deletions
diff --git a/tests/bench.lua b/tests/bench.lua index cae4902..648020b 100755 --- a/tests/bench.lua +++ b/tests/bench.lua | |||
@@ -115,7 +115,7 @@ function bench_file(filename) | |||
115 | end | 115 | end |
116 | 116 | ||
117 | -- Optionally load any custom configuration required for this module | 117 | -- Optionally load any custom configuration required for this module |
118 | local success, data = pcall(util.file_load, string.format("bench-%s.lua", json_module)) | 118 | local success, data = pcall(util.file_load, ("bench-%s.lua"):format(json_module)) |
119 | if success then | 119 | if success then |
120 | util.run_script(data, _G) | 120 | util.run_script(data, _G) |
121 | configure(json) | 121 | configure(json) |
@@ -124,7 +124,7 @@ end | |||
124 | for i = 1, #arg do | 124 | for i = 1, #arg do |
125 | local results = bench_file(arg[i]) | 125 | local results = bench_file(arg[i]) |
126 | for k, v in pairs(results) do | 126 | for k, v in pairs(results) do |
127 | print(string.format("%s\t%s\t%d", arg[i], k, v)) | 127 | print(("%s\t%s\t%d"):format(arg[i], k, v)) |
128 | end | 128 | end |
129 | end | 129 | end |
130 | 130 | ||
diff --git a/tests/test.lua b/tests/test.lua index e0f99f6..8c50b02 100755 --- a/tests/test.lua +++ b/tests/test.lua | |||
@@ -22,7 +22,7 @@ local function gen_utf16_escaped() | |||
22 | local count = 0 | 22 | local count = 0 |
23 | 23 | ||
24 | local function append_escape(code) | 24 | local function append_escape(code) |
25 | local esc = string.format('\\u%04X', code) | 25 | local esc = ('\\u%04X'):format(code) |
26 | table.insert(utf16_escaped, esc) | 26 | table.insert(utf16_escaped, esc) |
27 | end | 27 | end |
28 | 28 | ||
@@ -388,7 +388,7 @@ local cjson_tests = { | |||
388 | true, { false, 2, 10 } }, | 388 | true, { false, 2, 10 } }, |
389 | } | 389 | } |
390 | 390 | ||
391 | print(string.format("==> Testing Lua CJSON version %s\n", json._VERSION)) | 391 | print(("==> Testing Lua CJSON version %s\n"):format(json._VERSION)) |
392 | 392 | ||
393 | util.run_test_group(cjson_tests) | 393 | util.run_test_group(cjson_tests) |
394 | 394 | ||
@@ -402,7 +402,7 @@ local pass, total = util.run_test_summary() | |||
402 | if pass == total then | 402 | if pass == total then |
403 | print("==> Summary: all tests succeeded") | 403 | print("==> Summary: all tests succeeded") |
404 | else | 404 | else |
405 | print(string.format("==> Summary: %d/%d tests failed", total - pass, total)) | 405 | print(("==> Summary: %d/%d tests failed"):format(total - pass, total)) |
406 | os.exit(1) | 406 | os.exit(1) |
407 | end | 407 | end |
408 | 408 | ||