aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-03-18 00:55:13 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2017-03-18 01:06:53 +0800
commit5a71e4f1a7e856960d326be1743736cc04d3c238 (patch)
tree58b83b882dc06af3339d0dc9fdc3168e8cb5e794 /test
parentd5102c1db7cd2334e127ff684a6ecdd6aff156c6 (diff)
downloaddexon-solidity-5a71e4f1a7e856960d326be1743736cc04d3c238.tar.gz
dexon-solidity-5a71e4f1a7e856960d326be1743736cc04d3c238.tar.zst
dexon-solidity-5a71e4f1a7e856960d326be1743736cc04d3c238.zip
Add more complex tests for interfaces
Diffstat (limited to 'test')
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp35
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp17
2 files changed, 52 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index 7ef34383..8dd5042a 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -9266,6 +9266,41 @@ BOOST_AUTO_TEST_CASE(scientific_notation)
BOOST_CHECK(callContractFunction("k()") == encodeArgs(u256(-25)));
}
+BOOST_AUTO_TEST_CASE(interface)
+{
+ char const* sourceCode = R"(
+ interface I {
+ event A();
+ function f() returns (bool);
+ function() payable;
+ }
+
+ contract A is I {
+ function f() returns (bool) {
+ return g();
+ }
+
+ function g() returns (bool) {
+ return true;
+ }
+
+ function() payable {
+ }
+ }
+
+ contract C {
+ function f(address _interfaceAddress) returns (bool) {
+ I i = I(_interfaceAddress);
+ return i.f();
+ }
+ }
+ )";
+ compileAndRun(sourceCode, 0, "A");
+ u160 const recipient = m_contractAddress;
+ compileAndRun(sourceCode, 0, "C");
+ BOOST_CHECK(callContractFunction("f(address)", recipient) == encodeArgs(true));
+}
+
BOOST_AUTO_TEST_SUITE_END()
}
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index 39306f84..2a0f342c 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -5435,6 +5435,23 @@ BOOST_AUTO_TEST_CASE(using_interface)
success(text);
}
+BOOST_AUTO_TEST_CASE(using_interface_complex)
+{
+ char const* text = R"(
+ interface I {
+ event A();
+ function f();
+ function g();
+ function();
+ }
+ contract C is I {
+ function f() {
+ }
+ }
+ )";
+ success(text);
+}
+
BOOST_AUTO_TEST_SUITE_END()
}