From 5abddd2976535c80a31446b4920b12a8e7650794 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sun, 28 Apr 2019 19:16:28 +0200 Subject: [PATCH] scripts/check_site.lua: fix array_to_string with non-string/number array elements Fixes need_one_of() with boolean elements. --- scripts/check_site.lua | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/scripts/check_site.lua b/scripts/check_site.lua index 507fce83..0bac55de 100644 --- a/scripts/check_site.lua +++ b/scripts/check_site.lua @@ -65,8 +65,20 @@ local function path_to_string(path) return table.concat(path, '.') 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) - return '[' .. table.concat(array, ', ') .. ']' + local strings = {} + for i, v in ipairs(array) do + strings[i] = format(v) + end + return '[' .. table.concat(strings, ', ') .. ']' end function table_keys(tbl)