aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/SolidityEndToEndTest.cpp
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2016-10-14 18:27:46 +0800
committerchriseth <c@ethdev.com>2016-11-16 21:37:17 +0800
commit95d7555e3c0e8fc4826114a336e0e717fe7a1a2d (patch)
tree062dccd55852a8f0c768d16c9a6715f75c7b8c0f /test/libsolidity/SolidityEndToEndTest.cpp
parent6f19559de02e0bf2b53e743678d53a4ea0414eae (diff)
downloaddexon-solidity-95d7555e3c0e8fc4826114a336e0e717fe7a1a2d.tar.gz
dexon-solidity-95d7555e3c0e8fc4826114a336e0e717fe7a1a2d.tar.zst
dexon-solidity-95d7555e3c0e8fc4826114a336e0e717fe7a1a2d.zip
External functions in storage.
Diffstat (limited to 'test/libsolidity/SolidityEndToEndTest.cpp')
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp28
1 files changed, 27 insertions, 1 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index 709e63b2..b1529f8f 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -7695,7 +7695,33 @@ BOOST_AUTO_TEST_CASE(store_function)
BOOST_CHECK(callContractFunction("t()") == encodeArgs(u256(9)));
}
-// TODO: arrays, libraries
+BOOST_AUTO_TEST_CASE(function_type_library_internal)
+{
+ char const* sourceCode = R"(
+ library Utils {
+ function reduce(uint[] memory array, function(uint, uint) returns (uint) f, uint init) internal returns (uint) {
+ for (uint i = 0; i < array.length; i++) {
+ init = f(array[i], init);
+ }
+ return init;
+ }
+ function sum(uint a, uint b) internal returns (uint) {
+ return a + b;
+ }
+ }
+ contract C {
+ function f(uint[] x) returns (uint) {
+ return Utils.reduce(x, Utils.sum, 0);
+ }
+ }
+ )";
+
+ compileAndRun(sourceCode, 0, "C");
+ BOOST_CHECK(callContractFunction("f(uint256[])", 0x20, 3, u256(1), u256(7), u256(3)) == encodeArgs(u256(11)));
+}
+
+
+// TODO: arrays, libraries with external functions
BOOST_AUTO_TEST_CASE(shift_constant_left)
{