diff options
author | subtly <subtly@users.noreply.github.com> | 2015-06-27 18:55:53 +0800 |
---|---|---|
committer | subtly <subtly@users.noreply.github.com> | 2015-06-27 18:55:53 +0800 |
commit | 8e5daa7d88bb478634f44aec45a9c2c563e09856 (patch) | |
tree | bd315b556c4df6a51f298304ebb12fc450822d83 | |
parent | ae2f4acdc428af97f85f9ec703c61c3cfb0f8d54 (diff) | |
parent | a6d742ca177ba00ff99b5e9dad03a502e6b3bff0 (diff) | |
download | dexon-solidity-8e5daa7d88bb478634f44aec45a9c2c563e09856.tar.gz dexon-solidity-8e5daa7d88bb478634f44aec45a9c2c563e09856.tar.zst dexon-solidity-8e5daa7d88bb478634f44aec45a9c2c563e09856.zip |
Merge branch 'netFix' into rlpx
Conflicts:
libp2p/Session.cpp
-rw-r--r-- | libsolidity/SolidityEndToEndTest.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/libsolidity/SolidityEndToEndTest.cpp b/libsolidity/SolidityEndToEndTest.cpp index 75793abf..a01e98cf 100644 --- a/libsolidity/SolidityEndToEndTest.cpp +++ b/libsolidity/SolidityEndToEndTest.cpp @@ -4691,6 +4691,53 @@ BOOST_AUTO_TEST_CASE(memory_types_initialisation) BOOST_CHECK(callContractFunction("nestedStat()") == encodeArgs(vector<u256>(3 * 7))); } +BOOST_AUTO_TEST_CASE(memory_arrays_index_access_write) +{ + char const* sourceCode = R"( + contract Test { + function set(uint24[3][4] x) { + x[2][2] = 1; + x[3][2] = 7; + } + function f() returns (uint24[3][4]){ + uint24[3][4] memory data; + set(data); + return data; + } + } + )"; + compileAndRun(sourceCode, 0, "Test"); + + vector<u256> data(3 * 4); + data[3 * 2 + 2] = 1; + data[3 * 3 + 2] = 7; + BOOST_CHECK(callContractFunction("f()") == encodeArgs(data)); +} + +BOOST_AUTO_TEST_CASE(memory_arrays_dynamic_index_access_write) +{ + char const* sourceCode = R"( + contract Test { + uint24[3][][4] data; + function set(uint24[3][][4] x) internal returns (uint24[3][][4]) { + x[1][2][2] = 1; + x[1][3][2] = 7; + return x; + } + function f() returns (uint24[3][]) { + data[1].length = 4; + return set(data)[1]; + } + } + )"; + compileAndRun(sourceCode, 0, "Test"); + + vector<u256> data(3 * 4); + data[3 * 2 + 2] = 1; + data[3 * 3 + 2] = 7; + BOOST_CHECK(callContractFunction("f()") == encodeArgs(u256(0x20), u256(4), data)); +} + BOOST_AUTO_TEST_SUITE_END() } |