diff options
author | Lu Guanqun <guanqun.lu@gmail.com> | 2015-02-28 16:13:11 +0800 |
---|---|---|
committer | Lu Guanqun <guanqun.lu@gmail.com> | 2015-03-08 22:48:53 +0800 |
commit | 114776dfbaa1dd9e4b9c7a99b4314f628ccd9f0c (patch) | |
tree | 0c6b602236631130268f8f0d17f668824ebe5215 | |
parent | a1eed074329d2b3987b7ce105b5b50a174263da8 (diff) | |
download | dexon-solidity-114776dfbaa1dd9e4b9c7a99b4314f628ccd9f0c.tar dexon-solidity-114776dfbaa1dd9e4b9c7a99b4314f628ccd9f0c.tar.gz dexon-solidity-114776dfbaa1dd9e4b9c7a99b4314f628ccd9f0c.tar.bz2 dexon-solidity-114776dfbaa1dd9e4b9c7a99b4314f628ccd9f0c.tar.lz dexon-solidity-114776dfbaa1dd9e4b9c7a99b4314f628ccd9f0c.tar.xz dexon-solidity-114776dfbaa1dd9e4b9c7a99b4314f628ccd9f0c.tar.zst dexon-solidity-114776dfbaa1dd9e4b9c7a99b4314f628ccd9f0c.zip |
add end to end test cases related to overloaded functions
-rw-r--r-- | SolidityEndToEndTest.cpp | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/SolidityEndToEndTest.cpp b/SolidityEndToEndTest.cpp index ae241705..da5b29ad 100644 --- a/SolidityEndToEndTest.cpp +++ b/SolidityEndToEndTest.cpp @@ -3170,8 +3170,49 @@ BOOST_AUTO_TEST_CASE(pass_dynamic_arguments_to_the_base_base_with_gap) BOOST_CHECK(callContractFunction("m_i()") == encodeArgs(4)); } +BOOST_AUTO_TEST_CASE(overloaded_function_call_resolve_to_first) +{ + char const* sourceCode = R"( + contract test { + function f(uint k) returns(uint d) { return k; } + function f(uint a, uint b) returns(uint d) { return a + b; } + function g() returns(uint d) { return f(3); } + } + )"; + compileAndRun(sourceCode); + BOOST_CHECK(callContractFunction("g()") == encodeArgs(3)); +} -BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_CASE(overloaded_function_call_resolve_to_second) +{ + char const* sourceCode = R"( + contract test { + function f(uint a, uint b) returns(uint d) { return a + b; } + function f(uint k) returns(uint d) { return k; } + function g() returns(uint d) { return f(3, 7); } + } + )"; + compileAndRun(sourceCode); + BOOST_CHECK(callContractFunction("g()") == encodeArgs(10)); +} + +BOOST_AUTO_TEST_CASE(overloaded_function_call_with_if_else) +{ + char const* sourceCode = R"( + contract test { + function f(uint a, uint b) returns(uint d) { return a + b; } + function f(uint k) returns(uint d) { return k; } + function g(bool flag) returns(uint d) { + if (flag) + return f(3); + else + return f(3, 7); + } + } + )"; + BOOST_CHECK(callContractFunction("g(bool)", true) == encodeArgs(3)); + BOOST_CHECK(callContractFunction("g(bool)", false) == encodeArgs(10)); +} } } |