aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/SolidityParser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/libsolidity/SolidityParser.cpp')
-rw-r--r--test/libsolidity/SolidityParser.cpp106
1 files changed, 95 insertions, 11 deletions
diff --git a/test/libsolidity/SolidityParser.cpp b/test/libsolidity/SolidityParser.cpp
index 60ca03c9..72473c3e 100644
--- a/test/libsolidity/SolidityParser.cpp
+++ b/test/libsolidity/SolidityParser.cpp
@@ -167,6 +167,90 @@ BOOST_AUTO_TEST_CASE(single_function_param)
BOOST_CHECK(successParse(text));
}
+BOOST_AUTO_TEST_CASE(single_function_param_trailing_comma)
+{
+ char const* text = R"(
+ contract test {
+ function(uint a,) {}
+ }
+ )";
+ CHECK_PARSE_ERROR(text, "Unexpected trailing comma in parameter list.");
+}
+
+BOOST_AUTO_TEST_CASE(single_return_param_trailing_comma)
+{
+ char const* text = R"(
+ contract test {
+ function() returns (uint a,) {}
+ }
+ )";
+ CHECK_PARSE_ERROR(text, "Unexpected trailing comma in parameter list.");
+}
+
+BOOST_AUTO_TEST_CASE(single_modifier_arg_trailing_comma)
+{
+ char const* text = R"(
+ contract test {
+ modifier modTest(uint a,) { _; }
+ function(uint a) {}
+ }
+ )";
+ CHECK_PARSE_ERROR(text, "Unexpected trailing comma in parameter list.");
+}
+
+BOOST_AUTO_TEST_CASE(single_event_arg_trailing_comma)
+{
+ char const* text = R"(
+ contract test {
+ event Test(uint a,);
+ function(uint a) {}
+ }
+ )";
+ CHECK_PARSE_ERROR(text, "Unexpected trailing comma in parameter list.");
+}
+
+BOOST_AUTO_TEST_CASE(multiple_function_param_trailing_comma)
+{
+ char const* text = R"(
+ contract test {
+ function(uint a, uint b,) {}
+ }
+ )";
+ CHECK_PARSE_ERROR(text, "Unexpected trailing comma in parameter list.");
+}
+
+BOOST_AUTO_TEST_CASE(multiple_return_param_trailing_comma)
+{
+ char const* text = R"(
+ contract test {
+ function() returns (uint a, uint b,) {}
+ }
+ )";
+ CHECK_PARSE_ERROR(text, "Unexpected trailing comma in parameter list.");
+}
+
+BOOST_AUTO_TEST_CASE(multiple_modifier_arg_trailing_comma)
+{
+ char const* text = R"(
+ contract test {
+ modifier modTest(uint a, uint b,) { _; }
+ function(uint a) {}
+ }
+ )";
+ CHECK_PARSE_ERROR(text, "Unexpected trailing comma in parameter list.");
+}
+
+BOOST_AUTO_TEST_CASE(multiple_event_arg_trailing_comma)
+{
+ char const* text = R"(
+ contract test {
+ event Test(uint a, uint b,);
+ function(uint a) {}
+ }
+ )";
+ CHECK_PARSE_ERROR(text, "Unexpected trailing comma in parameter list.");
+}
+
BOOST_AUTO_TEST_CASE(function_no_body)
{
char const* text = R"(
@@ -250,7 +334,7 @@ BOOST_AUTO_TEST_CASE(function_natspec_documentation)
FunctionDefinition const* function = nullptr;
auto functions = contract->definedFunctions();
- ETH_TEST_REQUIRE_NO_THROW(function = functions.at(0), "Failed to retrieve function");
+ BOOST_REQUIRE_MESSAGE(function = functions.at(0), "Failed to retrieve function");
checkFunctionNatspec(function, "This is a test function");
}
@@ -268,7 +352,7 @@ BOOST_AUTO_TEST_CASE(function_normal_comments)
ErrorList errors;
ASTPointer<ContractDefinition> contract = parseText(text, errors);
auto functions = contract->definedFunctions();
- ETH_TEST_REQUIRE_NO_THROW(function = functions.at(0), "Failed to retrieve function");
+ BOOST_REQUIRE_MESSAGE(function = functions.at(0), "Failed to retrieve function");
BOOST_CHECK_MESSAGE(function->documentation() == nullptr,
"Should not have gotten a Natspecc comment for this function");
}
@@ -294,17 +378,17 @@ BOOST_AUTO_TEST_CASE(multiple_functions_natspec_documentation)
ASTPointer<ContractDefinition> contract = parseText(text, errors);
auto functions = contract->definedFunctions();
- ETH_TEST_REQUIRE_NO_THROW(function = functions.at(0), "Failed to retrieve function");
+ BOOST_REQUIRE_MESSAGE(function = functions.at(0), "Failed to retrieve function");
checkFunctionNatspec(function, "This is test function 1");
- ETH_TEST_REQUIRE_NO_THROW(function = functions.at(1), "Failed to retrieve function");
+ BOOST_REQUIRE_MESSAGE(function = functions.at(1), "Failed to retrieve function");
checkFunctionNatspec(function, "This is test function 2");
- ETH_TEST_REQUIRE_NO_THROW(function = functions.at(2), "Failed to retrieve function");
+ BOOST_REQUIRE_MESSAGE(function = functions.at(2), "Failed to retrieve function");
BOOST_CHECK_MESSAGE(function->documentation() == nullptr,
"Should not have gotten natspec comment for functionName3()");
- ETH_TEST_REQUIRE_NO_THROW(function = functions.at(3), "Failed to retrieve function");
+ BOOST_REQUIRE_MESSAGE(function = functions.at(3), "Failed to retrieve function");
checkFunctionNatspec(function, "This is test function 4");
}
@@ -323,7 +407,7 @@ BOOST_AUTO_TEST_CASE(multiline_function_documentation)
ErrorList errors;
ASTPointer<ContractDefinition> contract = parseText(text, errors);
auto functions = contract->definedFunctions();
- ETH_TEST_REQUIRE_NO_THROW(function = functions.at(0), "Failed to retrieve function");
+ BOOST_REQUIRE_MESSAGE(function = functions.at(0), "Failed to retrieve function");
checkFunctionNatspec(function, "This is a test function\n"
" and it has 2 lines");
}
@@ -351,10 +435,10 @@ BOOST_AUTO_TEST_CASE(natspec_comment_in_function_body)
ASTPointer<ContractDefinition> contract = parseText(text, errors);
auto functions = contract->definedFunctions();
- ETH_TEST_REQUIRE_NO_THROW(function = functions.at(0), "Failed to retrieve function");
+ BOOST_REQUIRE_MESSAGE(function = functions.at(0), "Failed to retrieve function");
checkFunctionNatspec(function, "fun1 description");
- ETH_TEST_REQUIRE_NO_THROW(function = functions.at(1), "Failed to retrieve function");
+ BOOST_REQUIRE_MESSAGE(function = functions.at(1), "Failed to retrieve function");
checkFunctionNatspec(function, "This is a test function\n"
" and it has 2 lines");
}
@@ -380,7 +464,7 @@ BOOST_AUTO_TEST_CASE(natspec_docstring_between_keyword_and_signature)
ASTPointer<ContractDefinition> contract = parseText(text, errors);
auto functions = contract->definedFunctions();
- ETH_TEST_REQUIRE_NO_THROW(function = functions.at(0), "Failed to retrieve function");
+ BOOST_REQUIRE_MESSAGE(function = functions.at(0), "Failed to retrieve function");
BOOST_CHECK_MESSAGE(!function->documentation(),
"Shouldn't get natspec docstring for this function");
}
@@ -406,7 +490,7 @@ BOOST_AUTO_TEST_CASE(natspec_docstring_after_signature)
ASTPointer<ContractDefinition> contract = parseText(text, errors);
auto functions = contract->definedFunctions();
- ETH_TEST_REQUIRE_NO_THROW(function = functions.at(0), "Failed to retrieve function");
+ BOOST_REQUIRE_MESSAGE(function = functions.at(0), "Failed to retrieve function");
BOOST_CHECK_MESSAGE(!function->documentation(),
"Shouldn't get natspec docstring for this function");
}