diff options
author | chriseth <c@ethdev.com> | 2015-10-15 23:37:15 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2015-10-15 23:37:15 +0800 |
commit | 7ba42f470753f9af25531017f319cf94eb26d3f2 (patch) | |
tree | 5d836e8f21fdd6afae13da36385ad0c0e53794fe /test/libsolidity | |
parent | e1e6a0c5319925f1f92f64279081c71738571272 (diff) | |
parent | a823de2d5863efb45e6d0a9d11e41f511687b831 (diff) | |
download | dexon-solidity-7ba42f470753f9af25531017f319cf94eb26d3f2.tar dexon-solidity-7ba42f470753f9af25531017f319cf94eb26d3f2.tar.gz dexon-solidity-7ba42f470753f9af25531017f319cf94eb26d3f2.tar.bz2 dexon-solidity-7ba42f470753f9af25531017f319cf94eb26d3f2.tar.lz dexon-solidity-7ba42f470753f9af25531017f319cf94eb26d3f2.tar.xz dexon-solidity-7ba42f470753f9af25531017f319cf94eb26d3f2.tar.zst dexon-solidity-7ba42f470753f9af25531017f319cf94eb26d3f2.zip |
Merge pull request #130 from LefterisJP/dynamic_array_push
Dynamic array push
Diffstat (limited to 'test/libsolidity')
-rw-r--r-- | test/libsolidity/SolidityEndToEndTest.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index cccca0ba..bee19010 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -3452,6 +3452,7 @@ BOOST_AUTO_TEST_CASE(array_copy_target_leftover2) asString(fromHex("0000000000000000")) )); } + BOOST_AUTO_TEST_CASE(array_copy_storage_storage_struct) { char const* sourceCode = R"( @@ -3476,6 +3477,45 @@ BOOST_AUTO_TEST_CASE(array_copy_storage_storage_struct) BOOST_CHECK(m_state.storage(m_contractAddress).empty()); } +BOOST_AUTO_TEST_CASE(array_push) +{ + char const* sourceCode = R"( + contract c { + uint[] data; + function test() returns (uint x, uint y, uint z, uint l) { + data.push(5); + x = data[0]; + data.push(4); + y = data[1]; + l = data.push(3); + z = data[2]; + } + } + )"; + compileAndRun(sourceCode); + BOOST_CHECK(callContractFunction("test()") == encodeArgs(5, 4, 3, 3)); +} + +BOOST_AUTO_TEST_CASE(byte_array_push) +{ + char const* sourceCode = R"( + contract c { + bytes data; + function test() returns (bool x) { + if (data.push(5) != 1) return true; + if (data[0] != 5) return true; + data.push(4); + if (data[1] != 4) return true; + uint l = data.push(3); + if (data[2] != 3) return true; + if (l != 3) return true; + } + } + )"; + compileAndRun(sourceCode); + BOOST_CHECK(callContractFunction("test()") == encodeArgs(false)); +} + BOOST_AUTO_TEST_CASE(external_array_args) { char const* sourceCode = R"( |