aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libsolidity/SolidityEndToEndTest.cpp47
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()
}
tr>* Use real PORTVERSION and update dependent portssunpoet2017-03-012-55/+58 * - Fix trailing whitespace in pkg-descrs, categories [p-x]*amdmi32016-05-191-1/+1 * Remove ${PORTSDIR}/ from dependencies, categories v, w, x, y, and z.mat2016-04-011-31/+31 * Make it so that the default Perl is always called perl5.mat2015-09-141-1/+1 * Clean up the rest of the perl@ Makefiles a bit.adamw2015-03-141-9/+9 * Fix shebang.mat2014-12-101-2/+3 * Change the way Perl modules are installed, update the default Perl to 5.18.mat2014-11-262-23/+1 * Support STAGEDIR.vanilla2013-11-072-62/+60 * Add NO_STAGE all over the place in preparation for the staging support (cat: ...bapt2013-09-211-0/+1 * - Use single space after WWW:sunpoet2013-08-291-1/+1 * - Convert to new perl frameworkmat2013-08-031-6/+3 * - Convert all remaining instances of BUILD_DEPENDS=${RUN_DEPENDS} orswills2012-06-111-1/+1