aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLiana Husikyan <liana@ethdev.com>2015-02-17 23:21:38 +0800
committerLiana Husikyan <liana@ethdev.com>2015-02-21 05:50:34 +0800
commit4144c63d9f1b7b25c4aaee29c21f412590aefe29 (patch)
tree36817bd21e577d0c62a2b53d42eb08d678b44a86
parent9281eb507d7dc05133fe87490a1299a0f8d74229 (diff)
downloaddexon-solidity-4144c63d9f1b7b25c4aaee29c21f412590aefe29.tar.gz
dexon-solidity-4144c63d9f1b7b25c4aaee29c21f412590aefe29.tar.zst
dexon-solidity-4144c63d9f1b7b25c4aaee29c21f412590aefe29.zip
Inline member initialisation
renamed VariableDefinition class to VariableDeclarationStatement added tests
-rw-r--r--SolidityEndToEndTest.cpp55
1 files changed, 55 insertions, 0 deletions
diff --git a/SolidityEndToEndTest.cpp b/SolidityEndToEndTest.cpp
index 8c87db2d..1f80b101 100644
--- a/SolidityEndToEndTest.cpp
+++ b/SolidityEndToEndTest.cpp
@@ -2570,6 +2570,61 @@ BOOST_AUTO_TEST_CASE(constructing_enums_from_ints)
BOOST_CHECK(callContractFunction("test()") == encodeArgs(1));
}
+BOOST_AUTO_TEST_CASE(inline_member_init)
+{
+ char const* sourceCode = R"(
+ contract test {
+ function test(){
+ m_b = 6;
+ m_c = 8;
+ }
+ uint m_a = 5;
+ uint m_b;
+ uint m_c = 7;
+ function get() returns (uint a, uint b, uint c){
+ a = m_a;
+ b = m_b;
+ c = m_c;
+ }
+ })";
+ compileAndRun(sourceCode);
+ BOOST_CHECK(callContractFunction("get()") == encodeArgs(5, 6, 8));
+}
+
+BOOST_AUTO_TEST_CASE(inline_member_init_inheritence)
+{
+ char const* sourceCode = R"(
+ contract Base {
+ function Base(){}
+ uint m_base = 5;
+ function getBMember() returns (uint i) { return m_base; }
+ }
+ contract Derived is Base {
+ function Derived(){}
+ uint m_derived = 6;
+ function getDMember() returns (uint i) { return m_derived; }
+ })";
+ compileAndRun(sourceCode);
+ BOOST_CHECK(callContractFunction("getBMember()") == encodeArgs(5));
+ BOOST_CHECK(callContractFunction("getDMember()") == encodeArgs(6));
+}
+
+BOOST_AUTO_TEST_CASE(inline_member_init_inheritence_without_constructor)
+{
+ char const* sourceCode = R"(
+ contract Base {
+ uint m_base = 5;
+ function getBMember() returns (uint i) { return m_base; }
+ }
+ contract Derived is Base {
+ uint m_derived = 6;
+ function getDMember() returns (uint i) { return m_derived; }
+ })";
+ compileAndRun(sourceCode);
+ BOOST_CHECK(callContractFunction("getBMember()") == encodeArgs(5));
+ BOOST_CHECK(callContractFunction("getDMember()") == encodeArgs(6));
+}
+
BOOST_AUTO_TEST_CASE(external_function)
{
char const* sourceCode = R"(