Parsing of not fully implemented functions

- Adding the possibility of omitting a function body by simply ending a
  function definition with a semicolon

- Such a function is marked as not fully implemented and any contract
  that contains such a function is considered a not fully implemented contract
This commit is contained in:
Lefteris Karapetsas 2015-03-20 17:50:26 +01:00
parent 0934d0e943
commit fc0b32f683
2 changed files with 23 additions and 0 deletions

View File

@ -346,6 +346,21 @@ BOOST_AUTO_TEST_CASE(comparison_bitop_precedence)
ETH_TEST_CHECK_NO_THROW(parseTextAndResolveNames(text), "Parsing and Name Resolving Failed");
}
BOOST_AUTO_TEST_CASE(function_no_implementation)
{
ASTPointer<SourceUnit> sourceUnit;
char const* text = "contract test {\n"
" function functionName(bytes32 input) returns (bytes32 out);\n"
"}\n";
ETH_TEST_REQUIRE_NO_THROW(sourceUnit = parseTextAndResolveNames(text), "Parsing and name Resolving failed");
ContractDefinition* contract;
for (ASTPointer<ASTNode> const& node: sourceUnit->getNodes())
contract = dynamic_cast<ContractDefinition*>(node.get());
BOOST_CHECK(contract);
BOOST_CHECK(!contract->isFullyImplemented());
BOOST_CHECK(!contract->getDefinedFunctions()[0]->isFullyImplemented());
}
BOOST_AUTO_TEST_CASE(function_canonical_signature)
{
ASTPointer<SourceUnit> sourceUnit;

View File

@ -108,6 +108,14 @@ BOOST_AUTO_TEST_CASE(single_function_param)
ETH_TEST_CHECK_NO_THROW(parseText(text), "Parsing failed.");
}
BOOST_AUTO_TEST_CASE(function_no_body)
{
char const* text = "contract test {\n"
" function functionName(bytes32 input) returns (bytes32 out);\n"
"}\n";
ETH_TEST_CHECK_NO_THROW(parseText(text), "Parsing failed.");
}
BOOST_AUTO_TEST_CASE(missing_parameter_name_in_named_args)
{
char const* text = "contract test {\n"