mirror of https://github.com/Icinga/icinga2.git
parent
1cb0231c05
commit
b40e95d9b6
|
@ -418,8 +418,9 @@ void icinga::BindToScope(Expression *& expr, ScopeSpecifier scopeSpec)
|
|||
}
|
||||
|
||||
LiteralExpression *lexpr = dynamic_cast<LiteralExpression *>(expr);
|
||||
ScriptFrame frame;
|
||||
|
||||
if (lexpr) {
|
||||
if (lexpr && lexpr->Evaluate(frame).IsString()) {
|
||||
Expression *scope = new GetScopeExpression(scopeSpec);
|
||||
expr = new IndexerExpression(scope, lexpr, lexpr->GetDebugInfo());
|
||||
}
|
||||
|
|
|
@ -234,6 +234,7 @@ BOOST_AUTO_TEST_CASE(advanced)
|
|||
|
||||
expr = ConfigCompiler::CompileText("<test>", "a = 3 b = 3");
|
||||
BOOST_CHECK_THROW(expr->Evaluate(frame), ScriptError);
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "function() { 3 }()");
|
||||
BOOST_CHECK(expr->Evaluate(frame) == 3);
|
||||
|
@ -290,6 +291,15 @@ BOOST_AUTO_TEST_CASE(advanced)
|
|||
expr = ConfigCompiler::CompileText("<test>", "7 & 15 > 6");
|
||||
BOOST_CHECK(expr->Evaluate(frame));
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "\"a\" = 3");
|
||||
BOOST_CHECK(expr->Evaluate(frame) == 3);
|
||||
BOOST_CHECK(frame.Locals->Get("a") == 3);
|
||||
delete expr;
|
||||
|
||||
expr = ConfigCompiler::CompileText("<test>", "3 = 3");
|
||||
BOOST_CHECK_THROW(expr->Evaluate(frame), ScriptError);
|
||||
delete expr;
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
|
Loading…
Reference in New Issue