aboutsummaryrefslogtreecommitdiffstats
path: root/tools/generate_format_spec.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-12-11 20:58:09 +0100
committerKim Alvefur <zash@zash.se>2021-12-11 20:58:09 +0100
commit725bb0cb15fd684ea82689c88c987177b37a8f0f (patch)
tree5bcef1a30c7b7872f2171473d6d1f8021dcc907d /tools/generate_format_spec.lua
parentd482ece962f9d003cb055316c5535eb5b5c719ef (diff)
downloadprosody-725bb0cb15fd684ea82689c88c987177b37a8f0f.tar.gz
prosody-725bb0cb15fd684ea82689c88c987177b37a8f0f.zip
tools/generate_format_spec: Apply lua-format to silence luacheck
Diffstat (limited to 'tools/generate_format_spec.lua')
-rw-r--r--tools/generate_format_spec.lua16
1 files changed, 9 insertions, 7 deletions
diff --git a/tools/generate_format_spec.lua b/tools/generate_format_spec.lua
index 66b68079..f5902327 100644
--- a/tools/generate_format_spec.lua
+++ b/tools/generate_format_spec.lua
@@ -1,5 +1,5 @@
local format = require"util.format".format;
-local dump = require "util.serialization".new("oneline")
+local dump = require"util.serialization".new("oneline")
local types = {
"nil";
"boolean";
@@ -13,8 +13,8 @@ local types = {
local example_values = {
["nil"] = { n = 1; nil };
["boolean"] = { true; false };
- ["number"] = { 97, -12345, 1.5; 73786976294838206464, math.huge, 2147483647 };
- ["string"] = { "hello", "foo \1\2\3 bar", "nödåtgärd", string.sub("nödåtgärd", 1, -4) };
+ ["number"] = { 97; -12345; 1.5; 73786976294838206464; math.huge; 2147483647 };
+ ["string"] = { "hello"; "foo \1\2\3 bar"; "nödåtgärd"; string.sub("nödåtgärd", 1, -4) };
["function"] = { function() end };
-- ["userdata"] = {};
["thread"] = { coroutine.create(function() end) };
@@ -23,7 +23,7 @@ local example_values = {
local example_strings = setmetatable({
["nil"] = { "nil" };
["function"] = { "function() end" };
- ["number"] = { "97", "-12345", "1.5"; "73786976294838206464", "math.huge", "2147483647" };
+ ["number"] = { "97"; "-12345"; "1.5"; "73786976294838206464"; "math.huge"; "2147483647" };
["thread"] = { "coroutine.create(function() end)" };
}, { __index = function() return {} end });
for _, lua_type in ipairs(types) do
@@ -32,12 +32,14 @@ for _, lua_type in ipairs(types) do
for fmt in ("cdiouxXaAeEfgGqs"):gmatch(".") do
print(string.format("\t\t\tdescribe(\"to %%%s\", function ()", fmt));
print("\t\t\t\tit(\"works\", function ()");
- for i=1, examples.n or #examples do
+ for i = 1, examples.n or #examples do
local example = examples[i];
if not tostring(example):match("%w+: 0[xX]%x+") then
- print(string.format("\t\t\t\t\tassert.equal(%q, format(%q, %s))", format("%"..fmt, example), "%" .. fmt, example_strings[lua_type][i] or dump(example)));
+ print(string.format("\t\t\t\t\tassert.equal(%q, format(%q, %s))", format("%" .. fmt, example), "%" .. fmt,
+ example_strings[lua_type][i] or dump(example)));
else
- print(string.format("\t\t\t\t\tassert.matches(\"[%s: 0[xX]%%x+]\", format(%q, %s))", lua_type, "%" .. fmt, example_strings[lua_type][i] or dump(example)));
+ print(string.format("\t\t\t\t\tassert.matches(\"[%s: 0[xX]%%x+]\", format(%q, %s))", lua_type, "%" .. fmt,
+ example_strings[lua_type][i] or dump(example)));
end
end
print("\t\t\t\tend);");