From ac3019298a42e87a2a9182b2a80a019e31d64f88 Mon Sep 17 00:00:00 2001 From: Lu Guanqun Date: Mon, 11 Jan 2016 16:50:47 +0800 Subject: [cond-expr] add a test for different types --- test/libsolidity/SolidityEndToEndTest.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'test/libsolidity/SolidityEndToEndTest.cpp') diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index 8bf309df..d7827946 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -174,6 +174,21 @@ BOOST_AUTO_TEST_CASE(conditional_expression_storage_memory) BOOST_CHECK(callContractFunction("f(bool)", false) == encodeArgs(u256(2))); } +BOOST_AUTO_TEST_CASE(conditional_expression_different_types) +{ + char const* sourceCode = R"( + contract test { + function f(bool cond) returns (uint) { + uint8 x = 0xcd; + uint16 y = 0xabab; + return cond ? x : y; + } + } + )"; + compileAndRun(sourceCode); + BOOST_CHECK(callContractFunction("f(bool)", true) == encodeArgs(u256(0xcd))); + BOOST_CHECK(callContractFunction("f(bool)", false) == encodeArgs(u256(0xabab))); +} BOOST_AUTO_TEST_CASE(recursive_calls) { char const* sourceCode = "contract test {\n" -- cgit