aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-10-11 18:28:21 +0800
committerchriseth <chris@ethereum.org>2017-10-17 04:29:31 +0800
commit6001bd1406e7adbb6607485afb775bbb5b6c2ac3 (patch)
tree7f5151acaf7e12f9b12818cfd20a95bf24f53849 /test/libsolidity
parent7989fc4c356929de47e2d696ef5478c398941508 (diff)
downloaddexon-solidity-6001bd1406e7adbb6607485afb775bbb5b6c2ac3.tar
dexon-solidity-6001bd1406e7adbb6607485afb775bbb5b6c2ac3.tar.gz
dexon-solidity-6001bd1406e7adbb6607485afb775bbb5b6c2ac3.tar.bz2
dexon-solidity-6001bd1406e7adbb6607485afb775bbb5b6c2ac3.tar.lz
dexon-solidity-6001bd1406e7adbb6607485afb775bbb5b6c2ac3.tar.xz
dexon-solidity-6001bd1406e7adbb6607485afb775bbb5b6c2ac3.tar.zst
dexon-solidity-6001bd1406e7adbb6607485afb775bbb5b6c2ac3.zip
Allocate one byte per memory byte array element instead of 32.
Diffstat (limited to 'test/libsolidity')
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index ac77a7e1..648c13cb 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -7309,6 +7309,30 @@ BOOST_AUTO_TEST_CASE(create_memory_array)
ABI_CHECK(callContractFunction("f()"), encodeArgs(string("A"), u256(8), u256(4), string("B")));
}
+BOOST_AUTO_TEST_CASE(create_memory_array_allocation_size)
+{
+ // Check allocation size of byte array. Should be 32 plus length rounded up to next
+ // multiple of 32
+ char const* sourceCode = R"(
+ contract C {
+ function f() pure returns (uint d1, uint d2, uint d3) {
+ bytes memory b1 = new bytes(31);
+ bytes memory b2 = new bytes(32);
+ bytes memory b3 = new bytes(256);
+ bytes memory b4 = new bytes(31);
+ assembly {
+ d1 := sub(b2, b1)
+ d2 := sub(b3, b2)
+ d3 := sub(b4, b3)
+ }
+ }
+ }
+ )";
+ compileAndRun(sourceCode);
+ ABI_CHECK(callContractFunction("f()"), encodeArgs(0x40, 0x40, 0x20 + 256));
+}
+
+
BOOST_AUTO_TEST_CASE(memory_arrays_of_various_sizes)
{
// Computes binomial coefficients the chinese way