|
@ -26,7 +26,7 @@ |
|
|
#include <libsolidity/Scanner.h> |
|
|
#include <libsolidity/Scanner.h> |
|
|
#include <libsolidity/Parser.h> |
|
|
#include <libsolidity/Parser.h> |
|
|
#include <libsolidity/Exceptions.h> |
|
|
#include <libsolidity/Exceptions.h> |
|
|
#include <boost/test/unit_test.hpp> |
|
|
#include "TestHelper.h" |
|
|
|
|
|
|
|
|
using namespace std; |
|
|
using namespace std; |
|
|
|
|
|
|
|
@ -50,22 +50,6 @@ ASTPointer<ContractDefinition> parseText(std::string const& _source) |
|
|
return ASTPointer<ContractDefinition>(); |
|
|
return ASTPointer<ContractDefinition>(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
ASTPointer<ContractDefinition> parseTextExplainError(std::string const& _source) |
|
|
|
|
|
{ |
|
|
|
|
|
try |
|
|
|
|
|
{ |
|
|
|
|
|
return parseText(_source); |
|
|
|
|
|
} |
|
|
|
|
|
catch (Exception const& exception) |
|
|
|
|
|
{ |
|
|
|
|
|
// LTODO: Print the error in a kind of a better way?
|
|
|
|
|
|
// In absence of CompilerStack we can't use SourceReferenceFormatter
|
|
|
|
|
|
cout << "Exception while parsing: " << diagnostic_information(exception); |
|
|
|
|
|
// rethrow to signal test failure
|
|
|
|
|
|
throw exception; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void checkFunctionNatspec(ASTPointer<FunctionDefinition> _function, |
|
|
static void checkFunctionNatspec(ASTPointer<FunctionDefinition> _function, |
|
|
std::string const& _expectedDoc) |
|
|
std::string const& _expectedDoc) |
|
|
{ |
|
|
{ |
|
@ -84,7 +68,7 @@ BOOST_AUTO_TEST_CASE(smoke_test) |
|
|
char const* text = "contract test {\n" |
|
|
char const* text = "contract test {\n" |
|
|
" uint256 stateVariable1;\n" |
|
|
" uint256 stateVariable1;\n" |
|
|
"}\n"; |
|
|
"}\n"; |
|
|
BOOST_CHECK_NO_THROW(parseText(text)); |
|
|
ETH_TEST_CHECK_NO_THROW(parseText(text), "Parsing failed."); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(missing_variable_name_in_declaration) |
|
|
BOOST_AUTO_TEST_CASE(missing_variable_name_in_declaration) |
|
@ -103,7 +87,7 @@ BOOST_AUTO_TEST_CASE(empty_function) |
|
|
" returns (int id)\n" |
|
|
" returns (int id)\n" |
|
|
" { }\n" |
|
|
" { }\n" |
|
|
"}\n"; |
|
|
"}\n"; |
|
|
BOOST_CHECK_NO_THROW(parseText(text)); |
|
|
ETH_TEST_CHECK_NO_THROW(parseText(text), "Parsing failed."); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(no_function_params) |
|
|
BOOST_AUTO_TEST_CASE(no_function_params) |
|
@ -112,7 +96,7 @@ BOOST_AUTO_TEST_CASE(no_function_params) |
|
|
" uint256 stateVar;\n" |
|
|
" uint256 stateVar;\n" |
|
|
" function functionName() {}\n" |
|
|
" function functionName() {}\n" |
|
|
"}\n"; |
|
|
"}\n"; |
|
|
BOOST_CHECK_NO_THROW(parseText(text)); |
|
|
ETH_TEST_CHECK_NO_THROW(parseText(text), "Parsing failed."); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(single_function_param) |
|
|
BOOST_AUTO_TEST_CASE(single_function_param) |
|
@ -121,7 +105,7 @@ BOOST_AUTO_TEST_CASE(single_function_param) |
|
|
" uint256 stateVar;\n" |
|
|
" uint256 stateVar;\n" |
|
|
" function functionName(hash hashin) returns (hash hashout) {}\n" |
|
|
" function functionName(hash hashin) returns (hash hashout) {}\n" |
|
|
"}\n"; |
|
|
"}\n"; |
|
|
BOOST_CHECK_NO_THROW(parseText(text)); |
|
|
ETH_TEST_CHECK_NO_THROW(parseText(text), "Parsing failed."); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(missing_parameter_name_in_named_args) |
|
|
BOOST_AUTO_TEST_CASE(missing_parameter_name_in_named_args) |
|
@ -151,9 +135,9 @@ BOOST_AUTO_TEST_CASE(function_natspec_documentation) |
|
|
" /// This is a test function\n" |
|
|
" /// This is a test function\n" |
|
|
" function functionName(hash hashin) returns (hash hashout) {}\n" |
|
|
" function functionName(hash hashin) returns (hash hashout) {}\n" |
|
|
"}\n"; |
|
|
"}\n"; |
|
|
BOOST_REQUIRE_NO_THROW(contract = parseText(text)); |
|
|
ETH_TEST_REQUIRE_NO_THROW(contract = parseText(text), "Parsing failed"); |
|
|
auto functions = contract->getDefinedFunctions(); |
|
|
auto functions = contract->getDefinedFunctions(); |
|
|
BOOST_REQUIRE_NO_THROW(function = functions.at(0)); |
|
|
ETH_TEST_REQUIRE_NO_THROW(function = functions.at(0), "Failed to retrieve function"); |
|
|
checkFunctionNatspec(function, "This is a test function"); |
|
|
checkFunctionNatspec(function, "This is a test function"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -166,9 +150,9 @@ BOOST_AUTO_TEST_CASE(function_normal_comments) |
|
|
" // We won't see this comment\n" |
|
|
" // We won't see this comment\n" |
|
|
" function functionName(hash hashin) returns (hash hashout) {}\n" |
|
|
" function functionName(hash hashin) returns (hash hashout) {}\n" |
|
|
"}\n"; |
|
|
"}\n"; |
|
|
BOOST_REQUIRE_NO_THROW(contract = parseText(text)); |
|
|
ETH_TEST_REQUIRE_NO_THROW(contract = parseText(text), "Parsing failed"); |
|
|
auto functions = contract->getDefinedFunctions(); |
|
|
auto functions = contract->getDefinedFunctions(); |
|
|
BOOST_REQUIRE_NO_THROW(function = functions.at(0)); |
|
|
ETH_TEST_REQUIRE_NO_THROW(function = functions.at(0), "Failed to retrieve function"); |
|
|
BOOST_CHECK_MESSAGE(function->getDocumentation() == nullptr, |
|
|
BOOST_CHECK_MESSAGE(function->getDocumentation() == nullptr, |
|
|
"Should not have gotten a Natspecc comment for this function"); |
|
|
"Should not have gotten a Natspecc comment for this function"); |
|
|
} |
|
|
} |
|
@ -188,20 +172,20 @@ BOOST_AUTO_TEST_CASE(multiple_functions_natspec_documentation) |
|
|
" /// This is test function 4\n" |
|
|
" /// This is test function 4\n" |
|
|
" function functionName4(hash hashin) returns (hash hashout) {}\n" |
|
|
" function functionName4(hash hashin) returns (hash hashout) {}\n" |
|
|
"}\n"; |
|
|
"}\n"; |
|
|
BOOST_REQUIRE_NO_THROW(contract = parseText(text)); |
|
|
ETH_TEST_REQUIRE_NO_THROW(contract = parseText(text), "Parsing failed"); |
|
|
auto functions = contract->getDefinedFunctions(); |
|
|
auto functions = contract->getDefinedFunctions(); |
|
|
|
|
|
|
|
|
BOOST_REQUIRE_NO_THROW(function = functions.at(0)); |
|
|
ETH_TEST_REQUIRE_NO_THROW(function = functions.at(0), "Failed to retrieve function"); |
|
|
checkFunctionNatspec(function, "This is test function 1"); |
|
|
checkFunctionNatspec(function, "This is test function 1"); |
|
|
|
|
|
|
|
|
BOOST_REQUIRE_NO_THROW(function = functions.at(1)); |
|
|
ETH_TEST_REQUIRE_NO_THROW(function = functions.at(1), "Failed to retrieve function"); |
|
|
checkFunctionNatspec(function, "This is test function 2"); |
|
|
checkFunctionNatspec(function, "This is test function 2"); |
|
|
|
|
|
|
|
|
BOOST_REQUIRE_NO_THROW(function = functions.at(2)); |
|
|
ETH_TEST_REQUIRE_NO_THROW(function = functions.at(2), "Failed to retrieve function"); |
|
|
BOOST_CHECK_MESSAGE(function->getDocumentation() == nullptr, |
|
|
BOOST_CHECK_MESSAGE(function->getDocumentation() == nullptr, |
|
|
"Should not have gotten natspec comment for functionName3()"); |
|
|
"Should not have gotten natspec comment for functionName3()"); |
|
|
|
|
|
|
|
|
BOOST_REQUIRE_NO_THROW(function = functions.at(3)); |
|
|
ETH_TEST_REQUIRE_NO_THROW(function = functions.at(3), "Failed to retrieve function"); |
|
|
checkFunctionNatspec(function, "This is test function 4"); |
|
|
checkFunctionNatspec(function, "This is test function 4"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -215,10 +199,10 @@ BOOST_AUTO_TEST_CASE(multiline_function_documentation) |
|
|
" /// and it has 2 lines\n" |
|
|
" /// and it has 2 lines\n" |
|
|
" function functionName1(hash hashin) returns (hash hashout) {}\n" |
|
|
" function functionName1(hash hashin) returns (hash hashout) {}\n" |
|
|
"}\n"; |
|
|
"}\n"; |
|
|
BOOST_REQUIRE_NO_THROW(contract = parseText(text)); |
|
|
ETH_TEST_REQUIRE_NO_THROW(contract = parseText(text), "Parsing failed"); |
|
|
auto functions = contract->getDefinedFunctions(); |
|
|
auto functions = contract->getDefinedFunctions(); |
|
|
|
|
|
|
|
|
BOOST_REQUIRE_NO_THROW(function = functions.at(0)); |
|
|
ETH_TEST_REQUIRE_NO_THROW(function = functions.at(0), "Failed to retrieve function"); |
|
|
checkFunctionNatspec(function, "This is a test function\n" |
|
|
checkFunctionNatspec(function, "This is a test function\n" |
|
|
" and it has 2 lines"); |
|
|
" and it has 2 lines"); |
|
|
} |
|
|
} |
|
@ -240,13 +224,13 @@ BOOST_AUTO_TEST_CASE(natspec_comment_in_function_body) |
|
|
" /// and it has 2 lines\n" |
|
|
" /// and it has 2 lines\n" |
|
|
" function fun(hash hashin) returns (hash hashout) {}\n" |
|
|
" function fun(hash hashin) returns (hash hashout) {}\n" |
|
|
"}\n"; |
|
|
"}\n"; |
|
|
BOOST_REQUIRE_NO_THROW(contract = parseText(text)); |
|
|
ETH_TEST_REQUIRE_NO_THROW(contract = parseText(text), "Parsing failed"); |
|
|
auto functions = contract->getDefinedFunctions(); |
|
|
auto functions = contract->getDefinedFunctions(); |
|
|
|
|
|
|
|
|
BOOST_REQUIRE_NO_THROW(function = functions.at(0)); |
|
|
ETH_TEST_REQUIRE_NO_THROW(function = functions.at(0), "Failed to retrieve function"); |
|
|
checkFunctionNatspec(function, "fun1 description"); |
|
|
checkFunctionNatspec(function, "fun1 description"); |
|
|
|
|
|
|
|
|
BOOST_REQUIRE_NO_THROW(function = functions.at(1)); |
|
|
ETH_TEST_REQUIRE_NO_THROW(function = functions.at(1), "Failed to retrieve function"); |
|
|
checkFunctionNatspec(function, "This is a test function\n" |
|
|
checkFunctionNatspec(function, "This is a test function\n" |
|
|
" and it has 2 lines"); |
|
|
" and it has 2 lines"); |
|
|
} |
|
|
} |
|
@ -266,10 +250,10 @@ BOOST_AUTO_TEST_CASE(natspec_docstring_between_keyword_and_signature) |
|
|
" string name = \"Solidity\";" |
|
|
" string name = \"Solidity\";" |
|
|
" }\n" |
|
|
" }\n" |
|
|
"}\n"; |
|
|
"}\n"; |
|
|
BOOST_REQUIRE_NO_THROW(contract = parseText(text)); |
|
|
ETH_TEST_REQUIRE_NO_THROW(contract = parseText(text), "Parsing failed"); |
|
|
auto functions = contract->getDefinedFunctions(); |
|
|
auto functions = contract->getDefinedFunctions(); |
|
|
|
|
|
|
|
|
BOOST_REQUIRE_NO_THROW(function = functions.at(0)); |
|
|
ETH_TEST_REQUIRE_NO_THROW(function = functions.at(0), "Failed to retrieve function"); |
|
|
BOOST_CHECK_MESSAGE(!function->getDocumentation(), |
|
|
BOOST_CHECK_MESSAGE(!function->getDocumentation(), |
|
|
"Shouldn't get natspec docstring for this function"); |
|
|
"Shouldn't get natspec docstring for this function"); |
|
|
} |
|
|
} |
|
@ -289,10 +273,10 @@ BOOST_AUTO_TEST_CASE(natspec_docstring_after_signature) |
|
|
" string name = \"Solidity\";" |
|
|
" string name = \"Solidity\";" |
|
|
" }\n" |
|
|
" }\n" |
|
|
"}\n"; |
|
|
"}\n"; |
|
|
BOOST_REQUIRE_NO_THROW(contract = parseText(text)); |
|
|
ETH_TEST_REQUIRE_NO_THROW(contract = parseText(text), "Parsing failed"); |
|
|
auto functions = contract->getDefinedFunctions(); |
|
|
auto functions = contract->getDefinedFunctions(); |
|
|
|
|
|
|
|
|
BOOST_REQUIRE_NO_THROW(function = functions.at(0)); |
|
|
ETH_TEST_REQUIRE_NO_THROW(function = functions.at(0), "Failed to retrieve function"); |
|
|
BOOST_CHECK_MESSAGE(!function->getDocumentation(), |
|
|
BOOST_CHECK_MESSAGE(!function->getDocumentation(), |
|
|
"Shouldn't get natspec docstring for this function"); |
|
|
"Shouldn't get natspec docstring for this function"); |
|
|
} |
|
|
} |
|
@ -306,7 +290,7 @@ BOOST_AUTO_TEST_CASE(struct_definition) |
|
|
" uint256 count;\n" |
|
|
" uint256 count;\n" |
|
|
" }\n" |
|
|
" }\n" |
|
|
"}\n"; |
|
|
"}\n"; |
|
|
BOOST_CHECK_NO_THROW(parseText(text)); |
|
|
ETH_TEST_CHECK_NO_THROW(parseText(text), "Parsing failed"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(mapping) |
|
|
BOOST_AUTO_TEST_CASE(mapping) |
|
@ -314,7 +298,7 @@ BOOST_AUTO_TEST_CASE(mapping) |
|
|
char const* text = "contract test {\n" |
|
|
char const* text = "contract test {\n" |
|
|
" mapping(address => string) names;\n" |
|
|
" mapping(address => string) names;\n" |
|
|
"}\n"; |
|
|
"}\n"; |
|
|
BOOST_CHECK_NO_THROW(parseText(text)); |
|
|
ETH_TEST_CHECK_NO_THROW(parseText(text), "Parsing failed"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(mapping_in_struct) |
|
|
BOOST_AUTO_TEST_CASE(mapping_in_struct) |
|
@ -326,7 +310,7 @@ BOOST_AUTO_TEST_CASE(mapping_in_struct) |
|
|
" mapping(hash => test_struct) self_reference;\n" |
|
|
" mapping(hash => test_struct) self_reference;\n" |
|
|
" }\n" |
|
|
" }\n" |
|
|
"}\n"; |
|
|
"}\n"; |
|
|
BOOST_CHECK_NO_THROW(parseText(text)); |
|
|
ETH_TEST_CHECK_NO_THROW(parseText(text), "Parsing failed"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(mapping_to_mapping_in_struct) |
|
|
BOOST_AUTO_TEST_CASE(mapping_to_mapping_in_struct) |
|
@ -337,7 +321,7 @@ BOOST_AUTO_TEST_CASE(mapping_to_mapping_in_struct) |
|
|
" mapping (uint64 => mapping (hash => uint)) complex_mapping;\n" |
|
|
" mapping (uint64 => mapping (hash => uint)) complex_mapping;\n" |
|
|
" }\n" |
|
|
" }\n" |
|
|
"}\n"; |
|
|
"}\n"; |
|
|
BOOST_CHECK_NO_THROW(parseText(text)); |
|
|
ETH_TEST_CHECK_NO_THROW(parseText(text), "Parsing failed"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(variable_definition) |
|
|
BOOST_AUTO_TEST_CASE(variable_definition) |
|
@ -350,7 +334,7 @@ BOOST_AUTO_TEST_CASE(variable_definition) |
|
|
" customtype varname;\n" |
|
|
" customtype varname;\n" |
|
|
" }\n" |
|
|
" }\n" |
|
|
"}\n"; |
|
|
"}\n"; |
|
|
BOOST_CHECK_NO_THROW(parseText(text)); |
|
|
ETH_TEST_CHECK_NO_THROW(parseText(text), "Parsing failed"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(variable_definition_with_initialization) |
|
|
BOOST_AUTO_TEST_CASE(variable_definition_with_initialization) |
|
@ -364,7 +348,7 @@ BOOST_AUTO_TEST_CASE(variable_definition_with_initialization) |
|
|
" customtype varname;\n" |
|
|
" customtype varname;\n" |
|
|
" }\n" |
|
|
" }\n" |
|
|
"}\n"; |
|
|
"}\n"; |
|
|
BOOST_CHECK_NO_THROW(parseText(text)); |
|
|
ETH_TEST_CHECK_NO_THROW(parseText(text), "Parsing failed"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(variable_definition_in_function_parameter) |
|
|
BOOST_AUTO_TEST_CASE(variable_definition_in_function_parameter) |
|
@ -408,7 +392,7 @@ BOOST_AUTO_TEST_CASE(operator_expression) |
|
|
" uint256 x = (1 + 4) || false && (1 - 12) + -9;\n" |
|
|
" uint256 x = (1 + 4) || false && (1 - 12) + -9;\n" |
|
|
" }\n" |
|
|
" }\n" |
|
|
"}\n"; |
|
|
"}\n"; |
|
|
BOOST_CHECK_NO_THROW(parseText(text)); |
|
|
ETH_TEST_CHECK_NO_THROW(parseText(text), "Parsing failed"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(complex_expression) |
|
|
BOOST_AUTO_TEST_CASE(complex_expression) |
|
@ -418,7 +402,7 @@ BOOST_AUTO_TEST_CASE(complex_expression) |
|
|
" uint256 x = (1 + 4).member(++67)[a/=9] || true;\n" |
|
|
" uint256 x = (1 + 4).member(++67)[a/=9] || true;\n" |
|
|
" }\n" |
|
|
" }\n" |
|
|
"}\n"; |
|
|
"}\n"; |
|
|
BOOST_CHECK_NO_THROW(parseText(text)); |
|
|
ETH_TEST_CHECK_NO_THROW(parseText(text), "Parsing failed"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(exp_expression) |
|
|
BOOST_AUTO_TEST_CASE(exp_expression) |
|
@ -429,7 +413,7 @@ BOOST_AUTO_TEST_CASE(exp_expression) |
|
|
uint256 x = 3 ** a; |
|
|
uint256 x = 3 ** a; |
|
|
} |
|
|
} |
|
|
})"; |
|
|
})"; |
|
|
BOOST_CHECK_NO_THROW(parseText(text)); |
|
|
ETH_TEST_CHECK_NO_THROW(parseText(text), "Parsing failed"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(while_loop) |
|
|
BOOST_AUTO_TEST_CASE(while_loop) |
|
@ -439,7 +423,7 @@ BOOST_AUTO_TEST_CASE(while_loop) |
|
|
" while (true) { uint256 x = 1; break; continue; } x = 9;\n" |
|
|
" while (true) { uint256 x = 1; break; continue; } x = 9;\n" |
|
|
" }\n" |
|
|
" }\n" |
|
|
"}\n"; |
|
|
"}\n"; |
|
|
BOOST_CHECK_NO_THROW(parseText(text)); |
|
|
ETH_TEST_CHECK_NO_THROW(parseText(text), "Parsing failed"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(for_loop_vardef_initexpr) |
|
|
BOOST_AUTO_TEST_CASE(for_loop_vardef_initexpr) |
|
@ -450,7 +434,7 @@ BOOST_AUTO_TEST_CASE(for_loop_vardef_initexpr) |
|
|
" { uint256 x = i; break; continue; }\n" |
|
|
" { uint256 x = i; break; continue; }\n" |
|
|
" }\n" |
|
|
" }\n" |
|
|
"}\n"; |
|
|
"}\n"; |
|
|
BOOST_CHECK_NO_THROW(parseTextExplainError(text)); |
|
|
ETH_TEST_CHECK_NO_THROW(parseText(text), "Parsing failed"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(for_loop_simple_initexpr) |
|
|
BOOST_AUTO_TEST_CASE(for_loop_simple_initexpr) |
|
@ -462,7 +446,7 @@ BOOST_AUTO_TEST_CASE(for_loop_simple_initexpr) |
|
|
" { uint256 x = i; break; continue; }\n" |
|
|
" { uint256 x = i; break; continue; }\n" |
|
|
" }\n" |
|
|
" }\n" |
|
|
"}\n"; |
|
|
"}\n"; |
|
|
BOOST_CHECK_NO_THROW(parseTextExplainError(text)); |
|
|
ETH_TEST_CHECK_NO_THROW(parseText(text), "Parsing failed"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(for_loop_simple_noexpr) |
|
|
BOOST_AUTO_TEST_CASE(for_loop_simple_noexpr) |
|
@ -474,7 +458,7 @@ BOOST_AUTO_TEST_CASE(for_loop_simple_noexpr) |
|
|
" { uint256 x = i; break; continue; }\n" |
|
|
" { uint256 x = i; break; continue; }\n" |
|
|
" }\n" |
|
|
" }\n" |
|
|
"}\n"; |
|
|
"}\n"; |
|
|
BOOST_CHECK_NO_THROW(parseTextExplainError(text)); |
|
|
ETH_TEST_CHECK_NO_THROW(parseText(text), "Parsing failed"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(for_loop_single_stmt_body) |
|
|
BOOST_AUTO_TEST_CASE(for_loop_single_stmt_body) |
|
@ -486,7 +470,7 @@ BOOST_AUTO_TEST_CASE(for_loop_single_stmt_body) |
|
|
" continue;\n" |
|
|
" continue;\n" |
|
|
" }\n" |
|
|
" }\n" |
|
|
"}\n"; |
|
|
"}\n"; |
|
|
BOOST_CHECK_NO_THROW(parseTextExplainError(text)); |
|
|
ETH_TEST_CHECK_NO_THROW(parseText(text), "Parsing failed"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(if_statement) |
|
|
BOOST_AUTO_TEST_CASE(if_statement) |
|
@ -496,7 +480,7 @@ BOOST_AUTO_TEST_CASE(if_statement) |
|
|
" if (a >= 8) return 2; else { var b = 7; }\n" |
|
|
" if (a >= 8) return 2; else { var b = 7; }\n" |
|
|
" }\n" |
|
|
" }\n" |
|
|
"}\n"; |
|
|
"}\n"; |
|
|
BOOST_CHECK_NO_THROW(parseText(text)); |
|
|
ETH_TEST_CHECK_NO_THROW(parseText(text), "Parsing failed"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(else_if_statement) |
|
|
BOOST_AUTO_TEST_CASE(else_if_statement) |
|
@ -506,7 +490,7 @@ BOOST_AUTO_TEST_CASE(else_if_statement) |
|
|
" if (a < 0) b = 0x67; else if (a == 0) b = 0x12; else b = 0x78;\n" |
|
|
" if (a < 0) b = 0x67; else if (a == 0) b = 0x12; else b = 0x78;\n" |
|
|
" }\n" |
|
|
" }\n" |
|
|
"}\n"; |
|
|
"}\n"; |
|
|
BOOST_CHECK_NO_THROW(parseText(text)); |
|
|
ETH_TEST_CHECK_NO_THROW(parseText(text), "Parsing failed"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(statement_starting_with_type_conversion) |
|
|
BOOST_AUTO_TEST_CASE(statement_starting_with_type_conversion) |
|
@ -518,7 +502,7 @@ BOOST_AUTO_TEST_CASE(statement_starting_with_type_conversion) |
|
|
" uint64[](3);\n" |
|
|
" uint64[](3);\n" |
|
|
" }\n" |
|
|
" }\n" |
|
|
"}\n"; |
|
|
"}\n"; |
|
|
BOOST_CHECK_NO_THROW(parseText(text)); |
|
|
ETH_TEST_CHECK_NO_THROW(parseText(text), "Parsing failed"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(type_conversion_to_dynamic_array) |
|
|
BOOST_AUTO_TEST_CASE(type_conversion_to_dynamic_array) |
|
@ -528,7 +512,7 @@ BOOST_AUTO_TEST_CASE(type_conversion_to_dynamic_array) |
|
|
" var x = uint64[](3);\n" |
|
|
" var x = uint64[](3);\n" |
|
|
" }\n" |
|
|
" }\n" |
|
|
"}\n"; |
|
|
"}\n"; |
|
|
BOOST_CHECK_NO_THROW(parseText(text)); |
|
|
ETH_TEST_CHECK_NO_THROW(parseText(text), "Parsing failed"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(import_directive) |
|
|
BOOST_AUTO_TEST_CASE(import_directive) |
|
@ -539,7 +523,7 @@ BOOST_AUTO_TEST_CASE(import_directive) |
|
|
" uint64(2);\n" |
|
|
" uint64(2);\n" |
|
|
" }\n" |
|
|
" }\n" |
|
|
"}\n"; |
|
|
"}\n"; |
|
|
BOOST_CHECK_NO_THROW(parseText(text)); |
|
|
ETH_TEST_CHECK_NO_THROW(parseText(text), "Parsing failed"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(multiple_contracts) |
|
|
BOOST_AUTO_TEST_CASE(multiple_contracts) |
|
@ -554,7 +538,7 @@ BOOST_AUTO_TEST_CASE(multiple_contracts) |
|
|
" uint64(2);\n" |
|
|
" uint64(2);\n" |
|
|
" }\n" |
|
|
" }\n" |
|
|
"}\n"; |
|
|
"}\n"; |
|
|
BOOST_CHECK_NO_THROW(parseText(text)); |
|
|
ETH_TEST_CHECK_NO_THROW(parseText(text), "Parsing failed"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(multiple_contracts_and_imports) |
|
|
BOOST_AUTO_TEST_CASE(multiple_contracts_and_imports) |
|
@ -572,7 +556,7 @@ BOOST_AUTO_TEST_CASE(multiple_contracts_and_imports) |
|
|
" }\n" |
|
|
" }\n" |
|
|
"}\n" |
|
|
"}\n" |
|
|
"import \"ghi\";\n"; |
|
|
"import \"ghi\";\n"; |
|
|
BOOST_CHECK_NO_THROW(parseText(text)); |
|
|
ETH_TEST_CHECK_NO_THROW(parseText(text), "Parsing failed"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(contract_inheritance) |
|
|
BOOST_AUTO_TEST_CASE(contract_inheritance) |
|
@ -587,7 +571,7 @@ BOOST_AUTO_TEST_CASE(contract_inheritance) |
|
|
" uint64(2);\n" |
|
|
" uint64(2);\n" |
|
|
" }\n" |
|
|
" }\n" |
|
|
"}\n"; |
|
|
"}\n"; |
|
|
BOOST_CHECK_NO_THROW(parseText(text)); |
|
|
ETH_TEST_CHECK_NO_THROW(parseText(text), "Parsing failed"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(contract_multiple_inheritance) |
|
|
BOOST_AUTO_TEST_CASE(contract_multiple_inheritance) |
|
@ -602,7 +586,7 @@ BOOST_AUTO_TEST_CASE(contract_multiple_inheritance) |
|
|
" uint64(2);\n" |
|
|
" uint64(2);\n" |
|
|
" }\n" |
|
|
" }\n" |
|
|
"}\n"; |
|
|
"}\n"; |
|
|
BOOST_CHECK_NO_THROW(parseText(text)); |
|
|
ETH_TEST_CHECK_NO_THROW(parseText(text), "Parsing failed"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(contract_multiple_inheritance_with_arguments) |
|
|
BOOST_AUTO_TEST_CASE(contract_multiple_inheritance_with_arguments) |
|
@ -617,7 +601,7 @@ BOOST_AUTO_TEST_CASE(contract_multiple_inheritance_with_arguments) |
|
|
" uint64(2);\n" |
|
|
" uint64(2);\n" |
|
|
" }\n" |
|
|
" }\n" |
|
|
"}\n"; |
|
|
"}\n"; |
|
|
BOOST_CHECK_NO_THROW(parseText(text)); |
|
|
ETH_TEST_CHECK_NO_THROW(parseText(text), "Parsing failed"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(placeholder_in_function_context) |
|
|
BOOST_AUTO_TEST_CASE(placeholder_in_function_context) |
|
@ -628,7 +612,7 @@ BOOST_AUTO_TEST_CASE(placeholder_in_function_context) |
|
|
" return _ + 1;" |
|
|
" return _ + 1;" |
|
|
" }\n" |
|
|
" }\n" |
|
|
"}\n"; |
|
|
"}\n"; |
|
|
BOOST_CHECK_NO_THROW(parseText(text)); |
|
|
ETH_TEST_CHECK_NO_THROW(parseText(text), "Parsing failed"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(modifier) |
|
|
BOOST_AUTO_TEST_CASE(modifier) |
|
@ -636,7 +620,7 @@ BOOST_AUTO_TEST_CASE(modifier) |
|
|
char const* text = "contract c {\n" |
|
|
char const* text = "contract c {\n" |
|
|
" modifier mod { if (msg.sender == 0) _ }\n" |
|
|
" modifier mod { if (msg.sender == 0) _ }\n" |
|
|
"}\n"; |
|
|
"}\n"; |
|
|
BOOST_CHECK_NO_THROW(parseText(text)); |
|
|
ETH_TEST_CHECK_NO_THROW(parseText(text), "Parsing failed"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(modifier_arguments) |
|
|
BOOST_AUTO_TEST_CASE(modifier_arguments) |
|
@ -644,7 +628,7 @@ BOOST_AUTO_TEST_CASE(modifier_arguments) |
|
|
char const* text = "contract c {\n" |
|
|
char const* text = "contract c {\n" |
|
|
" modifier mod(uint a) { if (msg.sender == a) _ }\n" |
|
|
" modifier mod(uint a) { if (msg.sender == a) _ }\n" |
|
|
"}\n"; |
|
|
"}\n"; |
|
|
BOOST_CHECK_NO_THROW(parseText(text)); |
|
|
ETH_TEST_CHECK_NO_THROW(parseText(text), "Parsing failed"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(modifier_invocation) |
|
|
BOOST_AUTO_TEST_CASE(modifier_invocation) |
|
@ -654,7 +638,7 @@ BOOST_AUTO_TEST_CASE(modifier_invocation) |
|
|
" modifier mod2 { if (msg.sender == 2) _ }\n" |
|
|
" modifier mod2 { if (msg.sender == 2) _ }\n" |
|
|
" function f() mod1(7) mod2 { }\n" |
|
|
" function f() mod1(7) mod2 { }\n" |
|
|
"}\n"; |
|
|
"}\n"; |
|
|
BOOST_CHECK_NO_THROW(parseText(text)); |
|
|
ETH_TEST_CHECK_NO_THROW(parseText(text), "Parsing failed"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(fallback_function) |
|
|
BOOST_AUTO_TEST_CASE(fallback_function) |
|
@ -662,7 +646,7 @@ BOOST_AUTO_TEST_CASE(fallback_function) |
|
|
char const* text = "contract c {\n" |
|
|
char const* text = "contract c {\n" |
|
|
" function() { }\n" |
|
|
" function() { }\n" |
|
|
"}\n"; |
|
|
"}\n"; |
|
|
BOOST_CHECK_NO_THROW(parseText(text)); |
|
|
ETH_TEST_CHECK_NO_THROW(parseText(text), "Parsing failed"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(event) |
|
|
BOOST_AUTO_TEST_CASE(event) |
|
@ -671,7 +655,7 @@ BOOST_AUTO_TEST_CASE(event) |
|
|
contract c { |
|
|
contract c { |
|
|
event e(); |
|
|
event e(); |
|
|
})"; |
|
|
})"; |
|
|
BOOST_CHECK_NO_THROW(parseText(text)); |
|
|
ETH_TEST_CHECK_NO_THROW(parseText(text), "Parsing failed"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(event_arguments) |
|
|
BOOST_AUTO_TEST_CASE(event_arguments) |
|
@ -680,7 +664,7 @@ BOOST_AUTO_TEST_CASE(event_arguments) |
|
|
contract c { |
|
|
contract c { |
|
|
event e(uint a, string32 s); |
|
|
event e(uint a, string32 s); |
|
|
})"; |
|
|
})"; |
|
|
BOOST_CHECK_NO_THROW(parseText(text)); |
|
|
ETH_TEST_CHECK_NO_THROW(parseText(text), "Parsing failed"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(event_arguments_indexed) |
|
|
BOOST_AUTO_TEST_CASE(event_arguments_indexed) |
|
@ -689,7 +673,7 @@ BOOST_AUTO_TEST_CASE(event_arguments_indexed) |
|
|
contract c { |
|
|
contract c { |
|
|
event e(uint a, string32 indexed s, bool indexed b); |
|
|
event e(uint a, string32 indexed s, bool indexed b); |
|
|
})"; |
|
|
})"; |
|
|
BOOST_CHECK_NO_THROW(parseText(text)); |
|
|
ETH_TEST_CHECK_NO_THROW(parseText(text), "Parsing failed"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(visibility_specifiers) |
|
|
BOOST_AUTO_TEST_CASE(visibility_specifiers) |
|
@ -705,7 +689,7 @@ BOOST_AUTO_TEST_CASE(visibility_specifiers) |
|
|
function f_public() public {} |
|
|
function f_public() public {} |
|
|
function f_internal() internal {} |
|
|
function f_internal() internal {} |
|
|
})"; |
|
|
})"; |
|
|
BOOST_CHECK_NO_THROW(parseText(text)); |
|
|
ETH_TEST_CHECK_NO_THROW(parseText(text), "Parsing failed"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(multiple_visibility_specifiers) |
|
|
BOOST_AUTO_TEST_CASE(multiple_visibility_specifiers) |
|
@ -733,7 +717,7 @@ BOOST_AUTO_TEST_CASE(literal_constants_with_ether_subdenominations) |
|
|
uint256 c; |
|
|
uint256 c; |
|
|
uint256 d; |
|
|
uint256 d; |
|
|
})"; |
|
|
})"; |
|
|
BOOST_CHECK_NO_THROW(parseTextExplainError(text)); |
|
|
ETH_TEST_CHECK_NO_THROW(parseText(text), "Parsing failed"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(literal_constants_with_ether_subdenominations_in_expressions) |
|
|
BOOST_AUTO_TEST_CASE(literal_constants_with_ether_subdenominations_in_expressions) |
|
@ -746,7 +730,7 @@ BOOST_AUTO_TEST_CASE(literal_constants_with_ether_subdenominations_in_expression |
|
|
} |
|
|
} |
|
|
uint256 a; |
|
|
uint256 a; |
|
|
})"; |
|
|
})"; |
|
|
BOOST_CHECK_NO_THROW(parseTextExplainError(text)); |
|
|
ETH_TEST_CHECK_NO_THROW(parseText(text), "Parsing failed"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(enum_valid_declaration) |
|
|
BOOST_AUTO_TEST_CASE(enum_valid_declaration) |
|
@ -760,7 +744,7 @@ BOOST_AUTO_TEST_CASE(enum_valid_declaration) |
|
|
} |
|
|
} |
|
|
uint256 a; |
|
|
uint256 a; |
|
|
})"; |
|
|
})"; |
|
|
BOOST_CHECK_NO_THROW(parseTextExplainError(text)); |
|
|
ETH_TEST_CHECK_NO_THROW(parseText(text), "Parsing failed"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(empty_enum_declaration) |
|
|
BOOST_AUTO_TEST_CASE(empty_enum_declaration) |
|
@ -769,7 +753,7 @@ BOOST_AUTO_TEST_CASE(empty_enum_declaration) |
|
|
contract c { |
|
|
contract c { |
|
|
enum foo { } |
|
|
enum foo { } |
|
|
})"; |
|
|
})"; |
|
|
BOOST_CHECK_NO_THROW(parseTextExplainError(text)); |
|
|
ETH_TEST_CHECK_NO_THROW(parseText(text), "Parsing failed"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(malformed_enum_declaration) |
|
|
BOOST_AUTO_TEST_CASE(malformed_enum_declaration) |
|
@ -787,7 +771,7 @@ BOOST_AUTO_TEST_CASE(external_function) |
|
|
contract c { |
|
|
contract c { |
|
|
function x() external {} |
|
|
function x() external {} |
|
|
})"; |
|
|
})"; |
|
|
BOOST_CHECK_NO_THROW(parseTextExplainError(text)); |
|
|
ETH_TEST_CHECK_NO_THROW(parseText(text), "Parsing failed"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(external_variable) |
|
|
BOOST_AUTO_TEST_CASE(external_variable) |
|
@ -808,7 +792,7 @@ BOOST_AUTO_TEST_CASE(arrays_in_storage) |
|
|
struct x { uint[2**20] b; y[0] c; } |
|
|
struct x { uint[2**20] b; y[0] c; } |
|
|
struct y { uint d; mapping(uint=>x)[] e; } |
|
|
struct y { uint d; mapping(uint=>x)[] e; } |
|
|
})"; |
|
|
})"; |
|
|
BOOST_CHECK_NO_THROW(parseText(text)); |
|
|
ETH_TEST_CHECK_NO_THROW(parseText(text), "Parsing failed"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(arrays_in_events) |
|
|
BOOST_AUTO_TEST_CASE(arrays_in_events) |
|
@ -817,7 +801,7 @@ BOOST_AUTO_TEST_CASE(arrays_in_events) |
|
|
contract c { |
|
|
contract c { |
|
|
event e(uint[10] a, string7[8] indexed b, c[3] x); |
|
|
event e(uint[10] a, string7[8] indexed b, c[3] x); |
|
|
})"; |
|
|
})"; |
|
|
BOOST_CHECK_NO_THROW(parseText(text)); |
|
|
ETH_TEST_CHECK_NO_THROW(parseText(text), "Parsing failed"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(arrays_in_expressions) |
|
|
BOOST_AUTO_TEST_CASE(arrays_in_expressions) |
|
@ -826,7 +810,7 @@ BOOST_AUTO_TEST_CASE(arrays_in_expressions) |
|
|
contract c { |
|
|
contract c { |
|
|
function f() { c[10] a = 7; uint8[10 * 2] x; } |
|
|
function f() { c[10] a = 7; uint8[10 * 2] x; } |
|
|
})"; |
|
|
})"; |
|
|
BOOST_CHECK_NO_THROW(parseText(text)); |
|
|
ETH_TEST_CHECK_NO_THROW(parseText(text), "Parsing failed"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(multi_arrays) |
|
|
BOOST_AUTO_TEST_CASE(multi_arrays) |
|
@ -835,7 +819,7 @@ BOOST_AUTO_TEST_CASE(multi_arrays) |
|
|
contract c { |
|
|
contract c { |
|
|
mapping(uint => mapping(uint => int8)[8][][9])[] x; |
|
|
mapping(uint => mapping(uint => int8)[8][][9])[] x; |
|
|
})"; |
|
|
})"; |
|
|
BOOST_CHECK_NO_THROW(parseText(text)); |
|
|
ETH_TEST_CHECK_NO_THROW(parseText(text), "Parsing failed"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_SUITE_END() |
|
|
BOOST_AUTO_TEST_SUITE_END() |
|
|