cover some edgecases and invalid tables in tests

This commit is contained in:
tour 2024-09-13 15:07:09 +02:00
parent 23f01fe6da
commit c0aaedae59

View File

@ -9,13 +9,27 @@ dofile(test_string_to_table.modpath .. "algtour.lua")
local tests = {
'{1, 2, 3}',
'{a = 1, b = 2, c = 3}',
'{a = 1; b = 2; c = 3}',
'{a = {b = {c = 3}}}',
'{1, "hello", true, false, nil, 3.14}',
'{[1] = "one", [2] = "two", ["three"] = 3}',
'{"quoted string", \'single quoted\'}',
'{nested = {tables = {are = {supported = true}}}}',
"{key1 = 123, key2 = true, key3 = {nestedKey1 = 'value1', nestedKey2 = false}}"
"{key1 = 123, key2 = true, key3 = {nestedKey1 = 'value1', nestedKey2 = false}}",
"{}", "{ }",
"{[{'tables can be'}] = 'keys too'}",
'{\'{table = "that", "contains", a = "string", ["looking"] = {"like", "a"; "table"}}\'}',
'{[-42.42e42] = 42.42E-42}',
'{1, 2, 3, }',
-- invalid tables, the code should return an error
-- --[[
"{a = 1",
"{'unclosed string\\'}",
"{invalid key = 3}",
"{1 = 2}", -- invalid key
"{,}",
"{[nil] = 1}"
--]]
}