aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/SolidityEndToEndTest.cpp
diff options
context:
space:
mode:
authorYoichi Hirai <i@yoichihirai.com>2016-10-14 23:54:12 +0800
committerchriseth <c@ethdev.com>2016-11-16 21:37:17 +0800
commit6172590b870832d7aa132209afb890125f301c15 (patch)
tree315ad5f08604c86eb249f49706f3ac67cdd7afc4 /test/libsolidity/SolidityEndToEndTest.cpp
parent708b7b35adc337500b9c42832f4a5461e7579e55 (diff)
downloaddexon-solidity-6172590b870832d7aa132209afb890125f301c15.tar.gz
dexon-solidity-6172590b870832d7aa132209afb890125f301c15.tar.zst
dexon-solidity-6172590b870832d7aa132209afb890125f301c15.zip
Add a test around storing functions in an array
Diffstat (limited to 'test/libsolidity/SolidityEndToEndTest.cpp')
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index 79dfd90e..704fc1a1 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -7750,6 +7750,45 @@ BOOST_AUTO_TEST_CASE(call_function_returning_function)
BOOST_CHECK(callContractFunction("f()") == encodeArgs(u256(2)));
}
+BOOST_AUTO_TEST_CASE(array_of_functions)
+{
+ char const* sourceCode = R"(
+ contract Flow {
+ bool success;
+ function checkSuccess() returns(bool) {
+ return success;
+ }
+
+ mapping (address => function () internal returns()) stages;
+
+ function stage0() internal {
+ stages[msg.sender] = stage1;
+ }
+
+ function stage1() internal {
+ stages[msg.sender] = stage2;
+ }
+
+ function stage2() internal {
+ success = true;
+ }
+
+ function f () {
+ if (0 == steps[msg.sender])
+ stages[msg.sender] = stage0;
+ stages[msg.sender]();
+ }
+ }
+ )";
+
+ compileAndRun(sourceCode, 0, "C");
+ BOOST_CHECK(callContractFunction("checkSuccess()") == encodeArgs(false));
+ callContractFunction("f()");
+ callContractFunction("f()");
+ BOOST_CHECK(callContractFunction("checkSuccess()") == encodeArgs(false));
+ callContractFunction("f()");
+ BOOST_CHECK(callContractFunction("checkSuccess()") == encodeArgs(true));
+}
// TODO: arrays, libraries with external functions