scripts/check_site.lua: fix array_to_string with non-string/number array elements

Fixes need_one_of() with boolean elements.
This commit is contained in:
Matthias Schiffer 2019-04-28 19:16:28 +02:00
parent ddb11ddd69
commit 5abddd2976
No known key found for this signature in database
GPG Key ID: 16EF3F64CB201D9C

View File

@ -65,8 +65,20 @@ local function path_to_string(path)
return table.concat(path, '.') return table.concat(path, '.')
end end
local function format(val)
if type(val) == 'string' then
return string.format('%q', val)
else
return tostring(val)
end
end
local function array_to_string(array) local function array_to_string(array)
return '[' .. table.concat(array, ', ') .. ']' local strings = {}
for i, v in ipairs(array) do
strings[i] = format(v)
end
return '[' .. table.concat(strings, ', ') .. ']'
end end
function table_keys(tbl) function table_keys(tbl)