From b003290638e16e595c25e433f2f65648ea6644da Mon Sep 17 00:00:00 2001 From: Lu Guanqun Date: Thu, 7 Jan 2016 09:14:29 +0000 Subject: [cond-expr] fixup according to code review --- test/libsolidity/SolidityEndToEndTest.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'test') 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) { -- cgit