escape table keys that map to lua keywords (#59)

This commit is contained in:
Simon Wachter
2023-01-19 13:16:48 +01:00
committed by GitHub
parent bac593278b
commit b738a52e35
3 changed files with 63 additions and 2 deletions

View File

@@ -111,6 +111,13 @@ describe( 'inspect', function()
end)
end
it('escapes string keys that are not valid identifiers', function()
assert.equals(unindent([[{
["if"] = true,
["key with spaces"] = true
}]]), inspect({['if'] = true, ['key with spaces'] = true}))
end)
it('works with simple dictionary tables', function()
assert.equals("{\n a = 1,\n b = 2\n}", inspect({a = 1, b = 2}))
end)