diff options
author | Lu Guanqun <guanqun.lu@gmail.com> | 2016-01-07 17:14:29 +0800 |
---|---|---|
committer | Lu Guanqun <guanqun.lu@gmail.com> | 2016-01-23 01:14:00 +0800 |
commit | b003290638e16e595c25e433f2f65648ea6644da (patch) | |
tree | 43acc605fae38011d22a2e01a820ff36d2154348 /test/libsolidity | |
parent | 82ee9503e9b3af35b55318f03caf3dc311a57539 (diff) | |
download | dexon-solidity-b003290638e16e595c25e433f2f65648ea6644da.tar.gz dexon-solidity-b003290638e16e595c25e433f2f65648ea6644da.tar.zst dexon-solidity-b003290638e16e595c25e433f2f65648ea6644da.zip |
[cond-expr] fixup according to code review
Diffstat (limited to 'test/libsolidity')
-rw-r--r-- | test/libsolidity/SolidityEndToEndTest.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index 46199578..3b9b8449 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -128,7 +128,6 @@ BOOST_AUTO_TEST_CASE(conditional_expression_multiple) BOOST_CHECK(callContractFunction("f(uint256)", u256(40)) == toBigEndian(u256(10))); } -/* BOOST_AUTO_TEST_CASE(conditional_expression_as_left_value) { char const* sourceCode = R"( @@ -144,7 +143,19 @@ BOOST_AUTO_TEST_CASE(conditional_expression_as_left_value) BOOST_CHECK(callContractFunction("f(uint256)", u256(20)) == toBigEndian(u256(3))); BOOST_CHECK(callContractFunction("f(uint256)", u256(5)) == toBigEndian(u256(1))); } -*/ + +BOOST_AUTO_TEST_CASE(conditional_expression_with_return_values) +{ + char const* sourceCode = R"( + contract test { + function f(bool cond, uint v) returns (uint a, uint b) { + cond ? a = v : b = v; + } + })"; + compileAndRun(sourceCode); + BOOST_CHECK(callContractFunction("f(bool,uint256)", true, u256(20)) == encodeArgs(u256(20), u256(0))); + BOOST_CHECK(callContractFunction("f(bool,uint256)", false, u256(20)) == encodeArgs(u256(0), u256(20))); +} BOOST_AUTO_TEST_CASE(recursive_calls) { |