diff options
author | Lefteris Karapetsas <lefteris@refu.co> | 2015-01-07 09:07:34 +0800 |
---|---|---|
committer | Lefteris Karapetsas <lefteris@refu.co> | 2015-01-07 09:07:34 +0800 |
commit | 36e5b5102a36aed554628b90909b055ab409ed1b (patch) | |
tree | a733b5bec81733866b139852d1e83d7ecb17c922 | |
parent | e50d4095a70673e69dcf576324486e0f5a61b1a1 (diff) | |
download | dexon-solidity-36e5b5102a36aed554628b90909b055ab409ed1b.tar.gz dexon-solidity-36e5b5102a36aed554628b90909b055ab409ed1b.tar.zst dexon-solidity-36e5b5102a36aed554628b90909b055ab409ed1b.zip |
Test for the Canonical Signature of a function
-rw-r--r-- | SolidityNameAndTypeResolution.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/SolidityNameAndTypeResolution.cpp b/SolidityNameAndTypeResolution.cpp index 25bff71f..e44c9fa2 100644 --- a/SolidityNameAndTypeResolution.cpp +++ b/SolidityNameAndTypeResolution.cpp @@ -38,7 +38,7 @@ namespace test namespace { -void parseTextAndResolveNames(std::string const& _source) +ASTPointer<SourceUnit> parseTextAndResolveNames(std::string const& _source) { Parser parser; ASTPointer<SourceUnit> sourceUnit = parser.parse(std::make_shared<Scanner>(CharStream(_source))); @@ -50,6 +50,8 @@ void parseTextAndResolveNames(std::string const& _source) for (ASTPointer<ASTNode> const& node: sourceUnit->getNodes()) if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get())) resolver.checkTypeRequirements(*contract); + + return sourceUnit; } } @@ -321,6 +323,23 @@ BOOST_AUTO_TEST_CASE(comparison_bitop_precedence) BOOST_CHECK_NO_THROW(parseTextAndResolveNames(text)); } +BOOST_AUTO_TEST_CASE(function_canonical_signature) +{ + ASTPointer<SourceUnit> sourceUnit; + char const* text = "contract Test {\n" + " function foo(uint256 arg1, uint64 arg2, bool arg3) returns (uint256 ret) {\n" + " ret = arg1 + arg2;\n" + " }\n" + "}\n"; + BOOST_CHECK_NO_THROW(sourceUnit = parseTextAndResolveNames(text)); + for (ASTPointer<ASTNode> const& node: sourceUnit->getNodes()) + if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get())) + { + auto functions = contract->getDefinedFunctions(); + BOOST_ASSERT("foo(uint256,uint64,bool)" == functions[0]->getCanonicalSignature()); + } +} + BOOST_AUTO_TEST_SUITE_END() } |