From e3dcc8a6106cc150a726b8569796840bb8962e06 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Tue, 3 Feb 2015 14:02:32 +0100 Subject: [PATCH] Implement a unit test for nullary lambdas fixes #7805 --- lib/base/function.hpp | 2 +- lib/icinga/macroprocessor.cpp | 3 +-- test/config-ops.cpp | 6 ++++++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/base/function.hpp b/lib/base/function.hpp index e19782d49..16c5285bb 100644 --- a/lib/base/function.hpp +++ b/lib/base/function.hpp @@ -44,7 +44,7 @@ public: Function(const Callback& function); - Value Invoke(const std::vector& arguments); + Value Invoke(const std::vector& arguments = std::vector()); static Object::Ptr GetPrototype(void); diff --git a/lib/icinga/macroprocessor.cpp b/lib/icinga/macroprocessor.cpp index e8e6259ba..8a578842b 100644 --- a/lib/icinga/macroprocessor.cpp +++ b/lib/icinga/macroprocessor.cpp @@ -184,8 +184,7 @@ Value MacroProcessor::EvaluateFunction(const Function::Ptr& func, const Resolver recursionLevel))); ScriptFrame frame(resolvers_this); - std::vector args; - return func->Invoke(args); + return func->Invoke(); } Value MacroProcessor::InternalResolveMacros(const String& str, const ResolverList& resolvers, diff --git a/test/config-ops.cpp b/test/config-ops.cpp index f9686d62c..4293b2497 100644 --- a/test/config-ops.cpp +++ b/test/config-ops.cpp @@ -209,6 +209,7 @@ BOOST_AUTO_TEST_CASE(advanced) { ScriptFrame frame; Expression *expr; + Function::Ptr func; expr = ConfigCompiler::CompileText("", "regex(\"^Hello\", \"Hello World\")"); BOOST_CHECK(expr->Evaluate(frame)); @@ -319,6 +320,11 @@ BOOST_AUTO_TEST_CASE(advanced) expr = ConfigCompiler::CompileText("", "Array.x"); BOOST_CHECK_THROW(expr->Evaluate(frame), ScriptError); delete expr; + + expr = ConfigCompiler::CompileText("", "{{ 3 }}"); + func = expr->Evaluate(frame); + BOOST_CHECK(func->Invoke() == 3); + delete expr; } BOOST_AUTO_TEST_SUITE_END()