helpers/lib: toLuaObject ignore empty attrs (#312)

This commit is contained in:
Gaétan Lepage 2023-04-03 11:25:37 +02:00 committed by GitHub
parent 3d64fab719
commit 35c56b62a1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 3 deletions

View file

@ -68,7 +68,7 @@
expected = ''"foo\\bar\nbaz"'';
};
testToLuaObjectShouldFilterNullAttrs = {
testToLuaObjectFilters = {
expr = helpers.toLuaObject {
a = null;
b = {};
@ -78,7 +78,21 @@
f = {};
};
};
expected = ''{["b"] = {},["c"] = {},["d"] = {["f"] = {}}}'';
expected = ''{}'';
};
testToLuaObjectEmptyTable = {
expr = helpers.toLuaObject {
a = null;
b = {};
c = {__empty = null;};
d = {
e = null;
f = {};
g = helpers.emptyTable;
};
};
expected = ''{["c"] = { },["d"] = {["g"] = { }}}'';
};
};
in