Update error message and add test case

This commit is contained in:
Florian Rival
2019-01-18 10:55:05 +00:00
parent a6360152cd
commit 0d864ce6a7
2 changed files with 15 additions and 3 deletions

View File

@@ -708,7 +708,7 @@ class GD_CORE_API ExpressionParser2 {
if (type == "number") {
message = _("You must enter a number or a valid expression call.");
} else if (type == "string") {
message = _("You must enter a text or a valid expression call.");
message = _("You must enter a text (between quotes) or a valid expression call.");
} else if (gd::ParameterMetadata::IsExpression("variable", type)) {
message = _("You must enter a variable name.");
} else if (type == "identifier") {

View File

@@ -52,8 +52,9 @@ TEST_CASE("ExpressionParser2", "[common][events]") {
gd::ExpressionValidator validator;
node->Visit(validator);
REQUIRE(validator.GetErrors().size() == 1);
REQUIRE(validator.GetErrors()[0]->GetMessage() ==
"You must enter a text or a valid expression call.");
REQUIRE(
validator.GetErrors()[0]->GetMessage() ==
"You must enter a text (between quotes) or a valid expression call.");
}
{
auto node = parser.ParseExpression("string", "abcd");
@@ -182,6 +183,17 @@ TEST_CASE("ExpressionParser2", "[common][events]") {
"This parameter was not expected by this expression. Remove it "
"or verify that you've entered the proper expression name.");
}
{
auto node = parser.ParseExpression("string", "=\"test\"");
REQUIRE(node != nullptr);
gd::ExpressionValidator validator;
node->Visit(validator);
REQUIRE(validator.GetErrors().size() == 1);
REQUIRE(
validator.GetErrors()[0]->GetMessage() ==
"You must enter a text (between quotes) or a valid expression call.");
}
}
SECTION("Invalid parenthesis") {