aboutsummaryrefslogtreecommitdiffstats
path: root/SolidityEndToEndTest.cpp
diff options
context:
space:
mode:
authorChristian <c@ethdev.com>2015-01-16 03:04:24 +0800
committerChristian <c@ethdev.com>2015-01-20 06:35:04 +0800
commitf84d8f2b504332438530abb2456dc2dc809587f6 (patch)
tree0ba1dd8ab3f6e8414f16d0cfb0ce3a8aa0a87d17 /SolidityEndToEndTest.cpp
parent70cda182f266e70e1cef065a6adb6862373785d5 (diff)
downloaddexon-solidity-f84d8f2b504332438530abb2456dc2dc809587f6.tar
dexon-solidity-f84d8f2b504332438530abb2456dc2dc809587f6.tar.gz
dexon-solidity-f84d8f2b504332438530abb2456dc2dc809587f6.tar.bz2
dexon-solidity-f84d8f2b504332438530abb2456dc2dc809587f6.tar.lz
dexon-solidity-f84d8f2b504332438530abb2456dc2dc809587f6.tar.xz
dexon-solidity-f84d8f2b504332438530abb2456dc2dc809587f6.tar.zst
dexon-solidity-f84d8f2b504332438530abb2456dc2dc809587f6.zip
Inheritance in compiler.
Diffstat (limited to 'SolidityEndToEndTest.cpp')
-rw-r--r--SolidityEndToEndTest.cpp60
1 files changed, 60 insertions, 0 deletions
diff --git a/SolidityEndToEndTest.cpp b/SolidityEndToEndTest.cpp
index dd57a1d1..934b39ad 100644
--- a/SolidityEndToEndTest.cpp
+++ b/SolidityEndToEndTest.cpp
@@ -1493,6 +1493,66 @@ BOOST_AUTO_TEST_CASE(value_for_constructor)
BOOST_REQUIRE(callContractFunction("getBalances()") == encodeArgs(12, 10));
}
+BOOST_AUTO_TEST_CASE(virtual_function_calls)
+{
+ char const* sourceCode = R"(
+ contract Base {
+ function f() returns (uint i) { return g(); }
+ function g() returns (uint i) { return 1; }
+ }
+ contract Derived is Base {
+ function g() returns (uint i) { return 2; }
+ }
+ )";
+ compileAndRun(sourceCode, 0, "Derived");
+ BOOST_CHECK(callContractFunction("g()") == encodeArgs(2));
+ BOOST_CHECK(callContractFunction("f()") == encodeArgs(2));
+}
+
+BOOST_AUTO_TEST_CASE(access_base_storage)
+{
+ char const* sourceCode = R"(
+ contract Base {
+ uint dataBase;
+ function getViaBase() returns (uint i) { return dataBase; }
+ }
+ contract Derived is Base {
+ uint dataDerived;
+ function setData(uint base, uint derived) returns (bool r) {
+ dataBase = base;
+ dataDerived = derived;
+ return true;
+ }
+ function getViaDerived() returns (uint base, uint derived) {
+ base = dataBase;
+ derived = dataDerived;
+ }
+ }
+ )";
+ compileAndRun(sourceCode, 0, "Derived");
+ BOOST_CHECK(callContractFunction("setData(uint256,uint256)", 1, 2) == encodeArgs(true));
+ BOOST_CHECK(callContractFunction("getViaBase()") == encodeArgs(1));
+ BOOST_CHECK(callContractFunction("getViaDerived()") == encodeArgs(1, 2));
+}
+
+BOOST_AUTO_TEST_CASE(single_copy_with_multiple_inheritance)
+{
+ char const* sourceCode = R"(
+ contract Base {
+ uint data;
+ function setData(uint i) { data = i; }
+ function getViaBase() returns (uint i) { return data; }
+ }
+ contract A is Base { function setViaA(uint i) { setData(i); } }
+ contract B is Base { function getViaB() returns (uint i) { return getViaBase(); } }
+ contract Derived is A, B, Base { }
+ )";
+ compileAndRun(sourceCode, 0, "Derived");
+ BOOST_CHECK(callContractFunction("getViaB()") == encodeArgs(0));
+ BOOST_CHECK(callContractFunction("setViaA(uint256)", 23) == encodeArgs());
+ BOOST_CHECK(callContractFunction("getViaB()") == encodeArgs(23));
+}
+
BOOST_AUTO_TEST_SUITE_END()
}