# HG changeset patch # User Kim Alvefur # Date 1639252689 -3600 # Node ID 82f6a0b0a4256938e5505b76525f2f01ae631a89 # Parent 2ce06f788093cc8b1ed9fca22cef250588b8c96a tools/generate_format_spec: Apply lua-format to silence luacheck diff -r 2ce06f788093 -r 82f6a0b0a425 tools/generate_format_spec.lua --- a/tools/generate_format_spec.lua Sat Dec 11 20:54:37 2021 +0100 +++ b/tools/generate_format_spec.lua Sat Dec 11 20:58:09 2021 +0100 @@ -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 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_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 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);");