aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-09-30 23:21:15 +0800
committerchriseth <c@ethdev.com>2015-10-06 20:19:30 +0800
commitd2332769d3e87b3500638591c23241ebd942fbb1 (patch)
tree244806e28aab4b41c19ad28ab35f7014598e0ec9 /test
parenta33d173ad9cb36660400765e4e55d3ec86b558da (diff)
downloaddexon-solidity-d2332769d3e87b3500638591c23241ebd942fbb1.tar
dexon-solidity-d2332769d3e87b3500638591c23241ebd942fbb1.tar.gz
dexon-solidity-d2332769d3e87b3500638591c23241ebd942fbb1.tar.bz2
dexon-solidity-d2332769d3e87b3500638591c23241ebd942fbb1.tar.lz
dexon-solidity-d2332769d3e87b3500638591c23241ebd942fbb1.tar.xz
dexon-solidity-d2332769d3e87b3500638591c23241ebd942fbb1.tar.zst
dexon-solidity-d2332769d3e87b3500638591c23241ebd942fbb1.zip
Test for internal types.
Diffstat (limited to 'test')
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index 86caacb6..c40a027a 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -5354,6 +5354,35 @@ BOOST_AUTO_TEST_CASE(fixed_arrays_as_return_type)
);
}
+BOOST_AUTO_TEST_CASE(internal_types_in_library)
+{
+ char const* sourceCode = R"(
+ library Lib {
+ function find(uint16[] storage _haystack, uint16 _needle) constant returns (uint)
+ {
+ for (uint i = 0; i < _haystack.length; ++i)
+ if (_haystack[i] == _needle)
+ return i;
+ return uint(-1);
+ }
+ }
+ contract Test {
+ mapping(string => uint16[]) data;
+ function f() returns (uint a, uint b)
+ {
+ data["abc"].length = 20;
+ data["abc"][4] = 9;
+ data["abc"][17] = 3;
+ a = Lib.find(data["abc"], 9);
+ b = Lib.find(data["abc"], 3);
+ }
+ }
+ )";
+ compileAndRun(sourceCode, 0, "Lib");
+ compileAndRun(sourceCode, 0, "Test", bytes(), map<string, Address>{{"Lib", m_contractAddress}});
+ BOOST_CHECK(callContractFunction("f()") == encodeArgs(u256(4), u256(17)));
+}
+
BOOST_AUTO_TEST_CASE(short_strings)
{
// This test verifies that the byte array encoding that combines length and data works