diff options
author | chriseth <c@ethdev.com> | 2016-10-11 05:06:44 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2016-11-16 21:37:17 +0800 |
commit | 97a3588701edafe9112f35272b5d4c6e23e574b9 (patch) | |
tree | ae688346b781554764aa15b638f076847af82504 /test/libsolidity | |
parent | dd173f83e3a6a9046d1aa7e64cb171598a73b272 (diff) | |
download | dexon-solidity-97a3588701edafe9112f35272b5d4c6e23e574b9.tar dexon-solidity-97a3588701edafe9112f35272b5d4c6e23e574b9.tar.gz dexon-solidity-97a3588701edafe9112f35272b5d4c6e23e574b9.tar.bz2 dexon-solidity-97a3588701edafe9112f35272b5d4c6e23e574b9.tar.lz dexon-solidity-97a3588701edafe9112f35272b5d4c6e23e574b9.tar.xz dexon-solidity-97a3588701edafe9112f35272b5d4c6e23e574b9.tar.zst dexon-solidity-97a3588701edafe9112f35272b5d4c6e23e574b9.zip |
Function type state variables.
Diffstat (limited to 'test/libsolidity')
-rw-r--r-- | test/libsolidity/SolidityEndToEndTest.cpp | 28 | ||||
-rw-r--r-- | test/libsolidity/SolidityParser.cpp | 21 |
2 files changed, 47 insertions, 2 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index 76df1970..0f392cab 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -7669,7 +7669,33 @@ BOOST_AUTO_TEST_CASE(pass_function_types_externally) BOOST_CHECK(callContractFunction("f2(uint256)", 7) == encodeArgs(u256(8))); } -// TODO: storage, arrays +BOOST_AUTO_TEST_CASE(store_function) +{ + char const* sourceCode = R"( + contract Other { + function addTwo(uint x) returns (uint) { return x + 2; } + } + contract C { + function (unction (uint) external returns (uint)) returns (uint) ev = eval; + function (uint) external returns (uint) x; + function store(function(uint) external returns (uint) y) { + x = y; + } + function eval(function(uint) external returns (uint) y) returns (uint) { + return y(7); + } + function t() returns (uint) { + this.store((new Other()).addTwo); + return ev(x); + } + } + )"; + + compileAndRun(sourceCode, 0, "C"); + BOOST_CHECK(callContractFunction("t()") == encodeArgs(u256(9))); +} + +// TODO: public function state variables, arrays BOOST_AUTO_TEST_CASE(shift_constant_left) { diff --git a/test/libsolidity/SolidityParser.cpp b/test/libsolidity/SolidityParser.cpp index 69b8d0f0..496f4703 100644 --- a/test/libsolidity/SolidityParser.cpp +++ b/test/libsolidity/SolidityParser.cpp @@ -1256,7 +1256,26 @@ BOOST_AUTO_TEST_CASE(function_type_in_expression) BOOST_AUTO_TEST_CASE(function_type_as_storage_variable) { - // TODO disambiguate from fallback function + char const* text = R"( + contract test { + function (uint, uint) internal returns (uint) f1; + } + )"; + BOOST_CHECK(successParse(text)); +} + +BOOST_AUTO_TEST_CASE(function_type_as_storage_variable_with_modifiers) +{ + char const* text = R"( + contract test { + function (uint, uint) modifier1() returns (uint) f1; + } + )"; + BOOST_CHECK(!successParse(text)); +} + +BOOST_AUTO_TEST_CASE(function_type_as_storage_variable_with_assignment) +{ char const* text = R"( contract test { function f(uint x, uint y) returns (uint a) {} |