From 873869c05f8cf8505d2275602248bad01cd9f8ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Del=20Pino?= <stephane.delpino44@gmail.com> Date: Thu, 19 May 2022 16:03:59 +0200 Subject: [PATCH] Simplify error message --- .../ast/ASTNodeIncDecExpressionBuilder.cpp | 2 +- tests/test_ASTNodeIncDecExpressionBuilder.cpp | 35 +++++++++---------- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/src/language/ast/ASTNodeIncDecExpressionBuilder.cpp b/src/language/ast/ASTNodeIncDecExpressionBuilder.cpp index 88b1758e7..93ffaf479 100644 --- a/src/language/ast/ASTNodeIncDecExpressionBuilder.cpp +++ b/src/language/ast/ASTNodeIncDecExpressionBuilder.cpp @@ -11,7 +11,7 @@ ASTNodeIncDecExpressionBuilder::ASTNodeIncDecExpressionBuilder(ASTNode& n) if (not n.children[0]->is_type<language::name>()) { std::ostringstream error_message; - error_message << "invalid operand type. ++/-- operators only apply to variables"; + error_message << "invalid operand type, expecting a variable"; throw ParseError(error_message.str(), std::vector{n.children[0]->begin()}); } diff --git a/tests/test_ASTNodeIncDecExpressionBuilder.cpp b/tests/test_ASTNodeIncDecExpressionBuilder.cpp index bc28df8ca..ac1c650a2 100644 --- a/tests/test_ASTNodeIncDecExpressionBuilder.cpp +++ b/tests/test_ASTNodeIncDecExpressionBuilder.cpp @@ -323,8 +323,7 @@ x--; ast->children.emplace_back(std::make_unique<ASTNode>()); - REQUIRE_THROWS_WITH(ASTNodeIncDecExpressionBuilder{*ast}, - "invalid operand type. ++/-- operators only apply to variables"); + REQUIRE_THROWS_WITH(ASTNodeIncDecExpressionBuilder{*ast}, "invalid operand type, expecting a variable"); } SECTION("Invalid data type") @@ -346,7 +345,7 @@ x--; 1 ++ ++; )"; - std::string error_message = R"(invalid operand type. ++/-- operators only apply to variables)"; + std::string error_message = R"(invalid operand type, expecting a variable)"; DISALLOWED_CHAINED_AST(data, error_message) } @@ -357,7 +356,7 @@ x--; 1 ++ --; )"; - std::string error_message = R"(invalid operand type. ++/-- operators only apply to variables)"; + std::string error_message = R"(invalid operand type, expecting a variable)"; DISALLOWED_CHAINED_AST(data, error_message) } @@ -368,7 +367,7 @@ x--; 1 -- ++; )"; - std::string error_message = R"(invalid operand type. ++/-- operators only apply to variables)"; + std::string error_message = R"(invalid operand type, expecting a variable)"; DISALLOWED_CHAINED_AST(data, error_message) } @@ -379,7 +378,7 @@ x--; 1 -- --; )"; - std::string error_message = R"(invalid operand type. ++/-- operators only apply to variables)"; + std::string error_message = R"(invalid operand type, expecting a variable)"; DISALLOWED_CHAINED_AST(data, error_message) } @@ -390,7 +389,7 @@ x--; ++ ++ 1; )"; - std::string error_message = R"(invalid operand type. ++/-- operators only apply to variables)"; + std::string error_message = R"(invalid operand type, expecting a variable)"; DISALLOWED_CHAINED_AST(data, error_message) } @@ -401,7 +400,7 @@ x--; ++ -- 1; )"; - std::string error_message = R"(invalid operand type. ++/-- operators only apply to variables)"; + std::string error_message = R"(invalid operand type, expecting a variable)"; DISALLOWED_CHAINED_AST(data, error_message) } @@ -412,7 +411,7 @@ x--; -- ++ 1; )"; - std::string error_message = R"(invalid operand type. ++/-- operators only apply to variables)"; + std::string error_message = R"(invalid operand type, expecting a variable)"; DISALLOWED_CHAINED_AST(data, error_message) } @@ -423,7 +422,7 @@ x--; -- -- 1; )"; - std::string error_message = R"(invalid operand type. ++/-- operators only apply to variables)"; + std::string error_message = R"(invalid operand type, expecting a variable)"; DISALLOWED_CHAINED_AST(data, error_message) } @@ -434,7 +433,7 @@ x--; ++ (1 ++); )"; - std::string error_message = R"(invalid operand type. ++/-- operators only apply to variables)"; + std::string error_message = R"(invalid operand type, expecting a variable)"; DISALLOWED_CHAINED_AST(data, error_message) } @@ -445,7 +444,7 @@ x--; ++ (1 --); )"; - std::string error_message = R"(invalid operand type. ++/-- operators only apply to variables)"; + std::string error_message = R"(invalid operand type, expecting a variable)"; DISALLOWED_CHAINED_AST(data, error_message) } @@ -456,7 +455,7 @@ x--; -- (1 ++); )"; - std::string error_message = R"(invalid operand type. ++/-- operators only apply to variables)"; + std::string error_message = R"(invalid operand type, expecting a variable)"; DISALLOWED_CHAINED_AST(data, error_message) } @@ -467,7 +466,7 @@ x--; -- (1 --); )"; - std::string error_message = R"(invalid operand type. ++/-- operators only apply to variables)"; + std::string error_message = R"(invalid operand type, expecting a variable)"; DISALLOWED_CHAINED_AST(data, error_message) } @@ -478,7 +477,7 @@ x--; (++ 1) ++; )"; - std::string error_message = R"(invalid operand type. ++/-- operators only apply to variables)"; + std::string error_message = R"(invalid operand type, expecting a variable)"; DISALLOWED_CHAINED_AST(data, error_message) } @@ -489,7 +488,7 @@ x--; (++ 1) --; )"; - std::string error_message = R"(invalid operand type. ++/-- operators only apply to variables)"; + std::string error_message = R"(invalid operand type, expecting a variable)"; DISALLOWED_CHAINED_AST(data, error_message) } @@ -500,7 +499,7 @@ x--; (-- 1) ++; )"; - std::string error_message = R"(invalid operand type. ++/-- operators only apply to variables)"; + std::string error_message = R"(invalid operand type, expecting a variable)"; DISALLOWED_CHAINED_AST(data, error_message) } @@ -511,7 +510,7 @@ x--; (-- 1) --; )"; - std::string error_message = R"(invalid operand type. ++/-- operators only apply to variables)"; + std::string error_message = R"(invalid operand type, expecting a variable)"; DISALLOWED_CHAINED_AST(data, error_message) } -- GitLab