diff options
author | chriseth <chris@ethereum.org> | 2018-04-04 20:37:43 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-04 20:37:43 +0800 |
commit | 2fe5607a5a6618f27f4ed5c1effb4273c662ee3a (patch) | |
tree | aef8f1dc5fa400e27ea5072f10c64f7ec5374b22 /test/libsolidity/SolidityEndToEndTest.cpp | |
parent | c5c5b23ff485075836b0b80db6e7cfebf0eebb4b (diff) | |
parent | 0cbe55005de79b0f7c5c770d50c3eb87df019789 (diff) | |
download | dexon-solidity-2fe5607a5a6618f27f4ed5c1effb4273c662ee3a.tar dexon-solidity-2fe5607a5a6618f27f4ed5c1effb4273c662ee3a.tar.gz dexon-solidity-2fe5607a5a6618f27f4ed5c1effb4273c662ee3a.tar.bz2 dexon-solidity-2fe5607a5a6618f27f4ed5c1effb4273c662ee3a.tar.lz dexon-solidity-2fe5607a5a6618f27f4ed5c1effb4273c662ee3a.tar.xz dexon-solidity-2fe5607a5a6618f27f4ed5c1effb4273c662ee3a.tar.zst dexon-solidity-2fe5607a5a6618f27f4ed5c1effb4273c662ee3a.zip |
Merge pull request #3721 from ethereum/simpleDynArray
Create empty dynamic memory arrays more efficiently.
Diffstat (limited to 'test/libsolidity/SolidityEndToEndTest.cpp')
-rw-r--r-- | test/libsolidity/SolidityEndToEndTest.cpp | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index 38d3ce4d..b58ebee4 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -7687,7 +7687,6 @@ BOOST_AUTO_TEST_CASE(create_memory_array_allocation_size) ABI_CHECK(callContractFunction("f()"), encodeArgs(0x40, 0x40, 0x20 + 256)); } - BOOST_AUTO_TEST_CASE(memory_arrays_of_various_sizes) { // Computes binomial coefficients the chinese way @@ -7710,6 +7709,41 @@ BOOST_AUTO_TEST_CASE(memory_arrays_of_various_sizes) ABI_CHECK(callContractFunction("f(uint256,uint256)", encodeArgs(u256(9), u256(5))), encodeArgs(u256(70))); } +BOOST_AUTO_TEST_CASE(create_multiple_dynamic_arrays) +{ + char const* sourceCode = R"( + contract C { + function f() returns (uint) { + uint[][] memory x = new uint[][](42); + assert(x[0].length == 0); + x[0] = new uint[](1); + x[0][0] = 1; + assert(x[4].length == 0); + x[4] = new uint[](1); + x[4][0] = 2; + assert(x[10].length == 0); + x[10] = new uint[](1); + x[10][0] = 44; + uint[][] memory y = new uint[][](24); + assert(y[0].length == 0); + y[0] = new uint[](1); + y[0][0] = 1; + assert(y[4].length == 0); + y[4] = new uint[](1); + y[4][0] = 2; + assert(y[10].length == 0); + y[10] = new uint[](1); + y[10][0] = 88; + if ((x[0][0] == y[0][0]) && (x[4][0] == y[4][0]) && (x[10][0] == 44) && (y[10][0] == 88)) + return 7; + return 0; + } + } + )"; + compileAndRun(sourceCode, 0, "C"); + ABI_CHECK(callContractFunction("f()"), encodeArgs(u256(7))); +} + BOOST_AUTO_TEST_CASE(memory_overwrite) { char const* sourceCode = R"( |