diff options
author | Lu Guanqun <guanqun.lu@gmail.com> | 2016-01-11 16:29:24 +0800 |
---|---|---|
committer | Lu Guanqun <guanqun.lu@gmail.com> | 2016-01-23 01:14:01 +0800 |
commit | 1cd32883117d7ae398b74797b7e33f077f6cd677 (patch) | |
tree | 96c7ad7e0b5cf34046d14de440cb3b8b41562253 /test | |
parent | 41039705ac1cb97e4174c735c160c3df5bc01722 (diff) | |
download | dexon-solidity-1cd32883117d7ae398b74797b7e33f077f6cd677.tar.gz dexon-solidity-1cd32883117d7ae398b74797b7e33f077f6cd677.tar.zst dexon-solidity-1cd32883117d7ae398b74797b7e33f077f6cd677.zip |
[cond-expr] add a test to assign memory to storage
Diffstat (limited to 'test')
-rw-r--r-- | test/libsolidity/SolidityEndToEndTest.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index be291735..8bf309df 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -141,6 +141,39 @@ BOOST_AUTO_TEST_CASE(conditional_expression_with_return_values) BOOST_CHECK(callContractFunction("f(bool,uint256)", false, u256(20)) == encodeArgs(u256(0), u256(20))); } +BOOST_AUTO_TEST_CASE(conditional_expression_storage_memory) +{ + char const* sourceCode = R"( + contract test { + bytes2[2] data1; + function f(bool cond) returns (uint) { + bytes2[2] memory x; + x[0] = "aa"; + bytes2[2] memory y; + y[0] = "bb"; + + data1 = cond ? x : y; + + uint ret = 0; + if (data1[0] == "aa") + { + ret = 1; + } + + if (data1[0] == "bb") + { + ret = 2; + } + + return ret; + } + } + )"; + compileAndRun(sourceCode); + BOOST_CHECK(callContractFunction("f(bool)", true) == encodeArgs(u256(1))); + BOOST_CHECK(callContractFunction("f(bool)", false) == encodeArgs(u256(2))); +} + BOOST_AUTO_TEST_CASE(recursive_calls) { char const* sourceCode = "contract test {\n" |