mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #1414 from LefterisJP/sol_notImplementedFuncs
Interface contracts
This commit is contained in:
commit
ea98b3b07e
@ -359,6 +359,63 @@ BOOST_AUTO_TEST_CASE(comparison_bitop_precedence)
|
|||||||
ETH_TEST_CHECK_NO_THROW(parseTextAndResolveNames(text), "Parsing and Name Resolving Failed");
|
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");
|
||||||
|
std::vector<ASTPointer<ASTNode>> nodes = sourceUnit->getNodes();
|
||||||
|
ContractDefinition* contract = dynamic_cast<ContractDefinition*>(nodes[0].get());
|
||||||
|
BOOST_CHECK(contract);
|
||||||
|
BOOST_CHECK(!contract->isFullyImplemented());
|
||||||
|
BOOST_CHECK(!contract->getDefinedFunctions()[0]->isFullyImplemented());
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(abstract_contract)
|
||||||
|
{
|
||||||
|
ASTPointer<SourceUnit> sourceUnit;
|
||||||
|
char const* text = R"(
|
||||||
|
contract base { function foo(); }
|
||||||
|
contract derived is base { function foo() {} }
|
||||||
|
)";
|
||||||
|
ETH_TEST_REQUIRE_NO_THROW(sourceUnit = parseTextAndResolveNames(text), "Parsing and name Resolving failed");
|
||||||
|
std::vector<ASTPointer<ASTNode>> nodes = sourceUnit->getNodes();
|
||||||
|
ContractDefinition* base = dynamic_cast<ContractDefinition*>(nodes[0].get());
|
||||||
|
ContractDefinition* derived = dynamic_cast<ContractDefinition*>(nodes[1].get());
|
||||||
|
BOOST_CHECK(base);
|
||||||
|
BOOST_CHECK(!base->isFullyImplemented());
|
||||||
|
BOOST_CHECK(!base->getDefinedFunctions()[0]->isFullyImplemented());
|
||||||
|
BOOST_CHECK(derived);
|
||||||
|
BOOST_CHECK(derived->isFullyImplemented());
|
||||||
|
BOOST_CHECK(derived->getDefinedFunctions()[0]->isFullyImplemented());
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(create_abstract_contract)
|
||||||
|
{
|
||||||
|
ASTPointer<SourceUnit> sourceUnit;
|
||||||
|
char const* text = R"(
|
||||||
|
contract base { function foo(); }
|
||||||
|
contract derived {
|
||||||
|
base b;
|
||||||
|
function foo() { b = new base();}
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError);
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(redeclare_implemented_abstract_function_as_abstract)
|
||||||
|
{
|
||||||
|
ASTPointer<SourceUnit> sourceUnit;
|
||||||
|
char const* text = R"(
|
||||||
|
contract base { function foo(); }
|
||||||
|
contract derived is base { function foo() {} }
|
||||||
|
contract wrong is derived { function foo(); }
|
||||||
|
)";
|
||||||
|
BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError);
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(function_canonical_signature)
|
BOOST_AUTO_TEST_CASE(function_canonical_signature)
|
||||||
{
|
{
|
||||||
ASTPointer<SourceUnit> sourceUnit;
|
ASTPointer<SourceUnit> sourceUnit;
|
||||||
|
@ -108,6 +108,14 @@ BOOST_AUTO_TEST_CASE(single_function_param)
|
|||||||
ETH_TEST_CHECK_NO_THROW(parseText(text), "Parsing failed.");
|
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)
|
BOOST_AUTO_TEST_CASE(missing_parameter_name_in_named_args)
|
||||||
{
|
{
|
||||||
char const* text = "contract test {\n"
|
char const* text = "contract test {\n"
|
||||||
|
Loading…
Reference in New Issue
Block a user