зеркало из https://github.com/microsoft/CCF.git
Support returning empty arrays from Lua (#1906)
This commit is contained in:
Родитель
6b64b2ac45
Коммит
5bf119fe7c
|
@ -301,6 +301,17 @@ TEST_CASE("json")
|
|||
REQUIRE(j.empty());
|
||||
}
|
||||
|
||||
SUBCASE("empty array")
|
||||
{
|
||||
// With some work, it is possible to build a table that will become an empty
|
||||
// JSON array
|
||||
constexpr auto code(
|
||||
"t = {}; setmetatable(t, {__was_object = false}); return t");
|
||||
const auto j = Interpreter().invoke<nlohmann::json>(code);
|
||||
REQUIRE(j.type() == nlohmann::json::value_t::array);
|
||||
REQUIRE(j.empty());
|
||||
}
|
||||
|
||||
SUBCASE("roundtrip empty object")
|
||||
{
|
||||
const auto j1 = nlohmann::json::object();
|
||||
|
|
|
@ -83,7 +83,15 @@ return {
|
|||
table.insert(self, {func=_func, args=_args})
|
||||
return self
|
||||
end
|
||||
Calls = setmetatable({}, {__index = __Calls})
|
||||
Calls = setmetatable({}, {__index = __Calls})
|
||||
|
||||
function empty_list()
|
||||
return setmetatable({}, {__was_object=false})
|
||||
end
|
||||
|
||||
function empty_object()
|
||||
return setmetatable({}, {__was_object=true})
|
||||
end
|
||||
]],
|
||||
|
||||
-- scripts that can be proposed to be called
|
||||
|
|
|
@ -106,7 +106,15 @@ return {
|
|||
table.insert(self, {func=_func, args=_args})
|
||||
return self
|
||||
end
|
||||
Calls = setmetatable({}, {__index = __Calls})
|
||||
Calls = setmetatable({}, {__index = __Calls})
|
||||
|
||||
function empty_list()
|
||||
return setmetatable({}, {__was_object=false})
|
||||
end
|
||||
|
||||
function empty_object()
|
||||
return setmetatable({}, {__was_object=true})
|
||||
end
|
||||
]],
|
||||
|
||||
-- scripts that can be proposed to be called
|
||||
|
|
|
@ -104,7 +104,15 @@ return {
|
|||
table.insert(self, {func=_func, args=_args})
|
||||
return self
|
||||
end
|
||||
Calls = setmetatable({}, {__index = __Calls})
|
||||
Calls = setmetatable({}, {__index = __Calls})
|
||||
|
||||
function empty_list()
|
||||
return setmetatable({}, {__was_object=false})
|
||||
end
|
||||
|
||||
function empty_object()
|
||||
return setmetatable({}, {__was_object=true})
|
||||
end
|
||||
]],
|
||||
|
||||
-- scripts that can be proposed to be called
|
||||
|
|
|
@ -87,7 +87,15 @@ return {
|
|||
table.insert(self, {func=_func, args=_args})
|
||||
return self
|
||||
end
|
||||
Calls = setmetatable({}, {__index = __Calls})
|
||||
Calls = setmetatable({}, {__index = __Calls})
|
||||
|
||||
function empty_list()
|
||||
return setmetatable({}, {__was_object=false})
|
||||
end
|
||||
|
||||
function empty_object()
|
||||
return setmetatable({}, {__was_object=true})
|
||||
end
|
||||
]],
|
||||
|
||||
-- scripts that can be proposed to be called
|
||||
|
|
|
@ -152,7 +152,15 @@ return {
|
|||
table.insert(self, {func=_func, args=_args})
|
||||
return self
|
||||
end
|
||||
Calls = setmetatable({}, {__index = __Calls})
|
||||
Calls = setmetatable({}, {__index = __Calls})
|
||||
|
||||
function empty_list()
|
||||
return setmetatable({}, {__was_object=false})
|
||||
end
|
||||
|
||||
function empty_object()
|
||||
return setmetatable({}, {__was_object=true})
|
||||
end
|
||||
]],
|
||||
|
||||
-- scripts that can be proposed to be called
|
||||
|
|
|
@ -46,7 +46,15 @@ return {
|
|||
table.insert(self, {func=_func, args=_args})
|
||||
return self
|
||||
end
|
||||
Calls = setmetatable({}, {__index = __Calls})
|
||||
Calls = setmetatable({}, {__index = __Calls})
|
||||
|
||||
function empty_list()
|
||||
return setmetatable({}, {__was_object=false})
|
||||
end
|
||||
|
||||
function empty_object()
|
||||
return setmetatable({}, {__was_object=true})
|
||||
end
|
||||
]],
|
||||
|
||||
-- scripts that can be proposed to be called
|
||||
|
|
Загрузка…
Ссылка в новой задаче