diff options
author | Lu Guanqun <guanqun.lu@gmail.com> | 2016-01-11 16:50:47 +0800 |
---|---|---|
committer | Lu Guanqun <guanqun.lu@gmail.com> | 2016-01-23 01:14:01 +0800 |
commit | ac3019298a42e87a2a9182b2a80a019e31d64f88 (patch) | |
tree | c0e3c657d4b78e2c31b4a71f30f1a77f14135a44 /test/libsolidity | |
parent | 1cd32883117d7ae398b74797b7e33f077f6cd677 (diff) | |
download | dexon-solidity-ac3019298a42e87a2a9182b2a80a019e31d64f88.tar dexon-solidity-ac3019298a42e87a2a9182b2a80a019e31d64f88.tar.gz dexon-solidity-ac3019298a42e87a2a9182b2a80a019e31d64f88.tar.bz2 dexon-solidity-ac3019298a42e87a2a9182b2a80a019e31d64f88.tar.lz dexon-solidity-ac3019298a42e87a2a9182b2a80a019e31d64f88.tar.xz dexon-solidity-ac3019298a42e87a2a9182b2a80a019e31d64f88.tar.zst dexon-solidity-ac3019298a42e87a2a9182b2a80a019e31d64f88.zip |
[cond-expr] add a test for different types
Diffstat (limited to 'test/libsolidity')
-rw-r--r-- | test/libsolidity/SolidityEndToEndTest.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
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" |