aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-04-22 01:13:46 +0800
committerchriseth <chris@ethereum.org>2017-04-25 22:49:04 +0800
commit478f2997ea8b233882d33e693a0e8df176a0c222 (patch)
tree2e18e560a737d85048d08884482426f439235eea /test
parent5f4b68e211a10af513d53cd2b9586191e174423d (diff)
downloaddexon-solidity-478f2997ea8b233882d33e693a0e8df176a0c222.tar
dexon-solidity-478f2997ea8b233882d33e693a0e8df176a0c222.tar.gz
dexon-solidity-478f2997ea8b233882d33e693a0e8df176a0c222.tar.bz2
dexon-solidity-478f2997ea8b233882d33e693a0e8df176a0c222.tar.lz
dexon-solidity-478f2997ea8b233882d33e693a0e8df176a0c222.tar.xz
dexon-solidity-478f2997ea8b233882d33e693a0e8df176a0c222.tar.zst
dexon-solidity-478f2997ea8b233882d33e693a0e8df176a0c222.zip
Storage access from inline assembly.
Diffstat (limited to 'test')
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp36
1 files changed, 33 insertions, 3 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index 019b0e4e..f2f4b8b0 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -7427,10 +7427,38 @@ BOOST_AUTO_TEST_CASE(inline_assembly_storage_access)
uint16 public y;
uint public z;
function f() returns (bool) {
+ uint off1;
+ uint off2;
+ assembly {
+ sstore(z_slot, 7)
+ off1 := z_offset
+ off2 := y_offset
+ }
+ assert(off1 == 0);
+ assert(off2 == 2);
+ return true;
+ }
+ }
+ )";
+ compileAndRun(sourceCode, 0, "C");
+ BOOST_CHECK(callContractFunction("f()") == encodeArgs(true));
+ BOOST_CHECK(callContractFunction("z()") == encodeArgs(u256(7)));
+}
+
+BOOST_AUTO_TEST_CASE(inline_assembly_storage_access_via_pointer)
+{
+ char const* sourceCode = R"(
+ contract C {
+ struct Data { uint contents; }
+ uint public separator;
+ Data public a;
+ uint public separator2;
+ function f() returns (bool) {
+ Data x = a;
uint off;
assembly {
- sstore(z$slot, 7)
- off := z$offset
+ sstore(x_slot, 7)
+ off := x_offset
}
assert(off == 0);
return true;
@@ -7439,7 +7467,9 @@ BOOST_AUTO_TEST_CASE(inline_assembly_storage_access)
)";
compileAndRun(sourceCode, 0, "C");
BOOST_CHECK(callContractFunction("f()") == encodeArgs(true));
- BOOST_CHECK(callContractFunction("z()") == encodeArgs(u256(7)));
+ BOOST_CHECK(callContractFunction("a()") == encodeArgs(u256(7)));
+ BOOST_CHECK(callContractFunction("separator()") == encodeArgs(u256(0)));
+ BOOST_CHECK(callContractFunction("separator2()") == encodeArgs(u256(0)));
}
BOOST_AUTO_TEST_CASE(inline_assembly_jumps)