diff options
author | Lu Guanqun <guanqun.lu@gmail.com> | 2015-03-06 11:37:51 +0800 |
---|---|---|
committer | Lu Guanqun <guanqun.lu@gmail.com> | 2015-03-08 22:50:54 +0800 |
commit | f5b1fec699c246d3f395a69db6dcf7e282c42113 (patch) | |
tree | fd6f306f162350ec9c0327d61077eebe988ad36a /SolidityEndToEndTest.cpp | |
parent | 1da211920e04ff385ac429d36ccafd4e10db7281 (diff) | |
download | dexon-solidity-f5b1fec699c246d3f395a69db6dcf7e282c42113.tar dexon-solidity-f5b1fec699c246d3f395a69db6dcf7e282c42113.tar.gz dexon-solidity-f5b1fec699c246d3f395a69db6dcf7e282c42113.tar.bz2 dexon-solidity-f5b1fec699c246d3f395a69db6dcf7e282c42113.tar.lz dexon-solidity-f5b1fec699c246d3f395a69db6dcf7e282c42113.tar.xz dexon-solidity-f5b1fec699c246d3f395a69db6dcf7e282c42113.tar.zst dexon-solidity-f5b1fec699c246d3f395a69db6dcf7e282c42113.zip |
add another var x = f; overloaded function test case
Diffstat (limited to 'SolidityEndToEndTest.cpp')
-rw-r--r-- | SolidityEndToEndTest.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/SolidityEndToEndTest.cpp b/SolidityEndToEndTest.cpp index 2beca784..dd34627a 100644 --- a/SolidityEndToEndTest.cpp +++ b/SolidityEndToEndTest.cpp @@ -3210,6 +3210,27 @@ BOOST_AUTO_TEST_CASE(overloaded_function_call_with_if_else) } } )"; + compileAndRun(sourceCode); + BOOST_CHECK(callContractFunction("g(bool)", true) == encodeArgs(3)); + BOOST_CHECK(callContractFunction("g(bool)", false) == encodeArgs(10)); +} + +BOOST_AUTO_TEST_CASE(overloaded_function_with_var) +{ + 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(bool flag) returns(uint d) { + var x = f; + if (flag) + return x(3); + else + return x(3, 7); + } + } + )"; + compileAndRun(sourceCode); BOOST_CHECK(callContractFunction("g(bool)", true) == encodeArgs(3)); BOOST_CHECK(callContractFunction("g(bool)", false) == encodeArgs(10)); } |