diff options
author | chriseth <c@ethdev.com> | 2015-07-01 03:03:23 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2015-07-03 23:25:30 +0800 |
commit | 3350f1d304c8f8ff01c2af506f7aca98bc9cdc40 (patch) | |
tree | d3c8c9d718ca28801977992200f98a77fe1346e4 | |
parent | fc8f83b84e9e7ac97ef41f88202baa9cec117405 (diff) | |
download | dexon-solidity-3350f1d304c8f8ff01c2af506f7aca98bc9cdc40.tar.gz dexon-solidity-3350f1d304c8f8ff01c2af506f7aca98bc9cdc40.tar.zst dexon-solidity-3350f1d304c8f8ff01c2af506f7aca98bc9cdc40.zip |
Fix for copying arrays to storage.
-rw-r--r-- | libsolidity/SolidityEndToEndTest.cpp | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/libsolidity/SolidityEndToEndTest.cpp b/libsolidity/SolidityEndToEndTest.cpp index 5ad8e6f3..c631b83b 100644 --- a/libsolidity/SolidityEndToEndTest.cpp +++ b/libsolidity/SolidityEndToEndTest.cpp @@ -4879,7 +4879,7 @@ BOOST_AUTO_TEST_CASE(memory_structs_as_function_args) BOOST_CHECK(callContractFunction("test()") == encodeArgs(u256(1), u256(2), u256(3))); } -BOOST_AUTO_TEST_CASE(memory_structs_wrapped) +BOOST_AUTO_TEST_CASE(memory_structs_nested) { char const* sourceCode = R"( contract Test { @@ -4911,42 +4911,51 @@ BOOST_AUTO_TEST_CASE(memory_structs_wrapped) BOOST_CHECK(callContractFunction("test()") == encodeArgs(u256(1), u256(2), u256(3), u256(4))); } -BOOST_AUTO_TEST_CASE(memory_structs_wrapped_load) +BOOST_AUTO_TEST_CASE(memory_structs_nested_load) { char const* sourceCode = R"( contract Test { struct S { uint8 x; uint16 y; uint z; } - struct X { uint8 x; S s; } + struct X { uint8 x; S s; uint8[2] a; } X m_x; - function load() returns (uint a, uint x, uint y, uint z) { + function load() returns (uint a, uint x, uint y, uint z, uint a1, uint a2) { m_x.x = 1; m_x.s.x = 2; m_x.s.y = 3; m_x.s.z = 4; + m_x.a[0] = 5; + m_x.a[1] = 6; X memory d = m_x; a = d.x; x = d.s.x; y = d.s.y; z = d.s.z; + a1 = d.a[0]; + a2 = d.a[1]; } - function store() returns (uint a, uint x, uint y, uint z) { - X memory d = m_x; + function store() returns (uint a, uint x, uint y, uint z, uint a1, uint a2) { + X memory d; d.x = 1; d.s.x = 2; d.s.y = 3; d.s.z = 4; + d.a[0] = 5; + d.a[1] = 6; m_x = d; a = m_x.x; x = m_x.s.x; y = m_x.s.y; z = m_x.s.z; + a1 = m_x.a[0]; + a2 = m_x.a[1]; } } )"; compileAndRun(sourceCode, 0, "Test"); - BOOST_CHECK(callContractFunction("load()") == encodeArgs(u256(1), u256(2), u256(3), u256(4))); - BOOST_CHECK(callContractFunction("store()") == encodeArgs(u256(1), u256(2), u256(3), u256(4))); + auto out = encodeArgs(u256(1), u256(2), u256(3), u256(4), u256(5), u256(6)); + BOOST_CHECK(callContractFunction("load()") == out); + BOOST_CHECK(callContractFunction("store()") == out); } BOOST_AUTO_TEST_SUITE_END() |