mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 00:25:42 +02:00
lib/lua: only quote table keys when needed
This commit is contained in:
parent
01cf43dbaa
commit
00ce71f51a
2 changed files with 25 additions and 13 deletions
|
@ -55,7 +55,7 @@ let
|
|||
3
|
||||
];
|
||||
};
|
||||
expected = ''{["foo"] = "bar",["qux"] = {1,2,3}}'';
|
||||
expected = ''{foo = "bar",qux = {1,2,3}}'';
|
||||
};
|
||||
|
||||
testToLuaObjectRawLua = {
|
||||
|
@ -68,7 +68,7 @@ let
|
|||
"__unkeyed...." = "foo";
|
||||
bar = "baz";
|
||||
};
|
||||
expected = ''{"foo",["bar"] = "baz"}'';
|
||||
expected = ''{"foo",bar = "baz"}'';
|
||||
};
|
||||
|
||||
testToLuaObjectNestedAttrs = {
|
||||
|
@ -81,7 +81,7 @@ let
|
|||
};
|
||||
};
|
||||
};
|
||||
expected = ''{["a"] = {["b"] = 1,["c"] = 2,["d"] = {["e"] = 3}}}'';
|
||||
expected = ''{a = {b = 1,c = 2,d = {e = 3}}}'';
|
||||
};
|
||||
|
||||
testToLuaObjectNestedList = {
|
||||
|
@ -109,7 +109,7 @@ let
|
|||
d = false;
|
||||
e = null;
|
||||
};
|
||||
expected = ''{["a"] = 1.000000,["b"] = 2,["c"] = true,["d"] = false}'';
|
||||
expected = ''{a = 1.000000,b = 2,c = true,d = false}'';
|
||||
};
|
||||
|
||||
testToLuaObjectNilPrim = {
|
||||
|
@ -150,7 +150,17 @@ let
|
|||
g = helpers.emptyTable;
|
||||
};
|
||||
};
|
||||
expected = ''{["c"] = { },["d"] = {["g"] = { }}}'';
|
||||
expected = ''{c = { },d = {g = { }}}'';
|
||||
};
|
||||
|
||||
testToLuaObjectQuotedKeys = {
|
||||
expr = helpers.toLuaObject {
|
||||
"1_a" = "a";
|
||||
_b = "b";
|
||||
c = "c";
|
||||
d-d = "d";
|
||||
};
|
||||
expected = ''{["1_a"] = "a",_b = "b",c = "c",["d-d"] = "d"}'';
|
||||
};
|
||||
|
||||
testIsLuaKeyword = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue