aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-06-10 00:28:13 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2017-09-16 19:12:43 +0800
commit823e67bf4014d20c6c83d509264e1464d9578f99 (patch)
tree12f54db4c441a59d5a4854ad627bb7e9937661df
parent080be885f835462f0074b05c617fa670402b067a (diff)
downloaddexon-solidity-823e67bf4014d20c6c83d509264e1464d9578f99.tar.gz
dexon-solidity-823e67bf4014d20c6c83d509264e1464d9578f99.tar.zst
dexon-solidity-823e67bf4014d20c6c83d509264e1464d9578f99.zip
Tests for external signatures.
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp32
1 files changed, 28 insertions, 4 deletions
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index 3cea8d60..9dfbea21 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -601,12 +601,36 @@ BOOST_AUTO_TEST_CASE(enum_external_type)
BOOST_AUTO_TEST_CASE(external_structs)
{
- BOOST_FAIL("This should test external structs");
- // More test ideas:
- // external function type as part of a struct and array
- // external function type taking structs and arrays...
+ ASTPointer<SourceUnit> sourceUnit;
+ char const* text = R"(
+ contract Test {
+ enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
+ struct Empty {}
+ struct Nested { X[2][] a; mapping(uint => uint) m; uint y; }
+ struct X { bytes32 x; Test t; Empty[] e; }
+ function f(ActionChoices, uint, Empty) external {}
+ function g(Nested) external {}
+ function h(function(Nested) external returns (uint)[]) external {}
+ function i(Nested[]) external {}
+ }
+ )";
+ ETH_TEST_REQUIRE_NO_THROW(sourceUnit = parseAndAnalyse(text), "Parsing and name Resolving failed");
+ for (ASTPointer<ASTNode> const& node: sourceUnit->nodes())
+ if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get()))
+ {
+ auto functions = contract->definedFunctions();
+ BOOST_REQUIRE(!functions.empty());
+ for (auto const& f: functions)
+ cout << f->externalSignature() << endl;
+ BOOST_CHECK_EQUAL("f(uint8,uint256,())", functions[0]->externalSignature());
+ BOOST_CHECK_EQUAL("g(((bytes32,address,()[])[2][],uint256))", functions[1]->externalSignature());
+ BOOST_CHECK_EQUAL("h(function[])", functions[2]->externalSignature());
+ BOOST_CHECK_EQUAL("i(((bytes32,address,()[])[2][],uint256)[])", functions[3]->externalSignature());
+ }
}
+// TODO: Add a test that checks the signature of library functions taking structs
+
BOOST_AUTO_TEST_CASE(function_external_call_allowed_conversion)
{
char const* text = R"(