From 31bf122c1d1d9e3812b9ef2555d537f509ae3f05 Mon Sep 17 00:00:00 2001 From: Mark Pulford Date: Thu, 19 Jan 2012 23:36:16 +1030 Subject: Simplify string.format() calls Simply string.format() calls with OO method notation. --- tests/bench.lua | 4 ++-- tests/test.lua | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'tests') 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) end -- Optionally load any custom configuration required for this module -local success, data = pcall(util.file_load, string.format("bench-%s.lua", json_module)) +local success, data = pcall(util.file_load, ("bench-%s.lua"):format(json_module)) if success then util.run_script(data, _G) configure(json) @@ -124,7 +124,7 @@ end for i = 1, #arg do local results = bench_file(arg[i]) for k, v in pairs(results) do - print(string.format("%s\t%s\t%d", arg[i], k, v)) + print(("%s\t%s\t%d"):format(arg[i], k, v)) end end 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() local count = 0 local function append_escape(code) - local esc = string.format('\\u%04X', code) + local esc = ('\\u%04X'):format(code) table.insert(utf16_escaped, esc) end @@ -388,7 +388,7 @@ local cjson_tests = { true, { false, 2, 10 } }, } -print(string.format("==> Testing Lua CJSON version %s\n", json._VERSION)) +print(("==> Testing Lua CJSON version %s\n"):format(json._VERSION)) util.run_test_group(cjson_tests) @@ -402,7 +402,7 @@ local pass, total = util.run_test_summary() if pass == total then print("==> Summary: all tests succeeded") else - print(string.format("==> Summary: %d/%d tests failed", total - pass, total)) + print(("==> Summary: %d/%d tests failed"):format(total - pass, total)) os.exit(1) end -- cgit v1.2.3-55-g6feb