renamed getCanonicalSignature

added externalTypes instead of types for interface functions
added simple test

todo
testing
This commit is contained in:
Liana Husikyan 2015-03-23 18:08:45 +01:00
parent 0934d0e943
commit 7e73fd3f45
2 changed files with 34 additions and 3 deletions

View File

@ -359,7 +359,7 @@ BOOST_AUTO_TEST_CASE(function_canonical_signature)
if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get()))
{
auto functions = contract->getDefinedFunctions();
BOOST_CHECK_EQUAL("foo(uint256,uint64,bool)", functions[0]->getCanonicalSignature());
BOOST_CHECK_EQUAL("foo(uint256,uint64,bool)", functions[0]->externalTypes());
}
}
@ -376,10 +376,41 @@ BOOST_AUTO_TEST_CASE(function_canonical_signature_type_aliases)
if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get()))
{
auto functions = contract->getDefinedFunctions();
BOOST_CHECK_EQUAL("boo(uint256,bytes32,address)", functions[0]->getCanonicalSignature());
BOOST_CHECK_EQUAL("boo(uint256,bytes32,address)", functions[0]->externalTypes());
}
}
BOOST_AUTO_TEST_CASE(function_external_types)
{
ASTPointer<SourceUnit> sourceUnit;
char const* text = R"(
contract Test {
function boo(uint arg2, bool arg3, bytes8 arg4) returns (uint ret) {
ret = 5;
}
})";
ETH_TEST_REQUIRE_NO_THROW(sourceUnit = parseTextAndResolveNames(text), "Parsing and name Resolving failed");
for (ASTPointer<ASTNode> const& node: sourceUnit->getNodes())
if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get()))
{
auto functions = contract->getDefinedFunctions();
BOOST_CHECK_EQUAL("boo(uint256,bool,bytes8)", functions[0]->externalTypes());
}
}
//todo should check arrays and contract. also event
//BOOST_AUTO_TEST_CASE(function_external_types_throw)
//{
// ASTPointer<SourceUnit> sourceUnit;
// char const* text = R"(
// contract Test {
// function boo(uint32[] arg5) returns (uint ret) {
// ret = 5;
// }
// })";
// BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError);
//}
BOOST_AUTO_TEST_CASE(hash_collision_in_interface)
{
char const* text = "contract test {\n"
@ -635,7 +666,6 @@ BOOST_AUTO_TEST_CASE(state_variable_accessors)
"mapping(uint=>bytes4) public map;\n"
"mapping(uint=>mapping(uint=>bytes4)) public multiple_map;\n"
"}\n";
ASTPointer<SourceUnit> source;
ContractDefinition const* contract;
ETH_TEST_CHECK_NO_THROW(source = parseTextAndResolveNames(text), "Parsing and Resolving names failed");

View File

@ -86,6 +86,7 @@ BOOST_AUTO_TEST_CASE(storage_layout_arrays)
BOOST_CHECK(ArrayType(ArrayType::Location::Storage, make_shared<FixedBytesType>(32), 9).getStorageSize() == 9);
}
BOOST_AUTO_TEST_SUITE_END()
}