Correctly delimit arguments when printing signature
Reviewers: mferencevic, ipaljak, llugovic Reviewed By: mferencevic, ipaljak Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D2732
This commit is contained in:
parent
d4c2798551
commit
2b8f068ca9
@ -1521,13 +1521,14 @@ std::ostream &PrintValue(const TypedValue &value, std::ostream *stream) {
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void PrintProcSignature(const mgp_proc &proc, std::ostream *stream) {
|
||||
(*stream) << proc.name << "(";
|
||||
utils::PrintIterable(
|
||||
*stream, proc.args, ", ", [](auto &stream, const auto &arg) {
|
||||
stream << arg.first << " :: " << arg.second->GetPresentableName();
|
||||
});
|
||||
if (!proc.opt_args.empty()) (*stream) << ", ";
|
||||
if (!proc.args.empty() && !proc.opt_args.empty()) (*stream) << ", ";
|
||||
utils::PrintIterable(
|
||||
*stream, proc.opt_args, ", ", [](auto &stream, const auto &arg) {
|
||||
stream << std::get<0>(arg) << " = ";
|
||||
|
@ -90,3 +90,12 @@ TEST(Module, ProcedureSignature) {
|
||||
"opt2 = \"string=\\\"value\\\"\" :: STRING) :: "
|
||||
"(res1 :: LIST OF INTEGER, DEPRECATED res2 :: STRING)");
|
||||
}
|
||||
|
||||
TEST(Module, ProcedureSignatureOnlyOptArg) {
|
||||
mgp_memory memory{utils::NewDeleteResource()};
|
||||
mgp_module module(utils::NewDeleteResource());
|
||||
auto *proc = mgp_module_add_read_procedure(&module, "proc", DummyCallback);
|
||||
mgp_proc_add_opt_arg(proc, "opt1", mgp_type_nullable(mgp_type_any()),
|
||||
mgp_value_make_null(&memory));
|
||||
CheckSignature(proc, "proc(opt1 = Null :: ANY?) :: ()");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user