aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-03-30 18:11:07 +0800
committerchriseth <chris@ethereum.org>2018-04-03 20:34:32 +0800
commite64e397f2417fc9a678690614a775fa88514f1dc (patch)
treecccd811956f9b3c1d1eb0e565bb443545f44565f
parent138dba1a3fbb475a21a546bc39a55a746647439b (diff)
downloaddexon-solidity-e64e397f2417fc9a678690614a775fa88514f1dc.tar
dexon-solidity-e64e397f2417fc9a678690614a775fa88514f1dc.tar.gz
dexon-solidity-e64e397f2417fc9a678690614a775fa88514f1dc.tar.bz2
dexon-solidity-e64e397f2417fc9a678690614a775fa88514f1dc.tar.lz
dexon-solidity-e64e397f2417fc9a678690614a775fa88514f1dc.tar.xz
dexon-solidity-e64e397f2417fc9a678690614a775fa88514f1dc.tar.zst
dexon-solidity-e64e397f2417fc9a678690614a775fa88514f1dc.zip
Add memory array init test.
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index 7fd65c14..38d3ce4d 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -8756,6 +8756,32 @@ BOOST_AUTO_TEST_CASE(create_dynamic_array_with_zero_length)
ABI_CHECK(callContractFunction("f()"), encodeArgs(u256(7)));
}
+BOOST_AUTO_TEST_CASE(correctly_initialize_memory_array_in_constructor)
+{
+ // Memory arrays are initialized using codecopy past the size of the code.
+ // This test checks that it also works in the constructor context.
+ char const* sourceCode = R"(
+ contract C {
+ bool public success;
+ function C() public {
+ // Make memory dirty.
+ assembly {
+ for { let i := 0 } lt(i, 64) { i := add(i, 1) } {
+ mstore(msize, not(0))
+ }
+ }
+ uint16[3] memory c;
+ require(c[0] == 0 && c[1] == 0 && c[2] == 0);
+ uint16[] memory x = new uint16[](3);
+ require(x[0] == 0 && x[1] == 0 && x[2] == 0);
+ success = true;
+ }
+ }
+ )";
+ compileAndRun(sourceCode, 0, "C");
+ ABI_CHECK(callContractFunction("success()"), encodeArgs(u256(1)));
+}
+
BOOST_AUTO_TEST_CASE(return_does_not_skip_modifier)
{
char const* sourceCode = R"(