diff options
author | Christian <c@ethdev.com> | 2014-12-19 05:15:11 +0800 |
---|---|---|
committer | Christian <c@ethdev.com> | 2014-12-19 05:23:34 +0800 |
commit | beb060672675a4b658a7d7aa39169043bce1cfaf (patch) | |
tree | 8f795957725e323e61b3173d53a48eb9c0352b47 /SolidityEndToEndTest.cpp | |
parent | da29d945e21b0519b75b8c06107d3b903427d051 (diff) | |
download | dexon-solidity-beb060672675a4b658a7d7aa39169043bce1cfaf.tar.gz dexon-solidity-beb060672675a4b658a7d7aa39169043bce1cfaf.tar.zst dexon-solidity-beb060672675a4b658a7d7aa39169043bce1cfaf.zip |
Bugfix: Additional swap for compound assignment.
Diffstat (limited to 'SolidityEndToEndTest.cpp')
-rw-r--r-- | SolidityEndToEndTest.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/SolidityEndToEndTest.cpp b/SolidityEndToEndTest.cpp index aa74f818..9559e370 100644 --- a/SolidityEndToEndTest.cpp +++ b/SolidityEndToEndTest.cpp @@ -504,6 +504,41 @@ BOOST_AUTO_TEST_CASE(state_smoke_test) BOOST_CHECK(callContractFunction(0, bytes(1, 0x00)) == toBigEndian(u256(0x3))); } +BOOST_AUTO_TEST_CASE(compound_assign) +{ + char const* sourceCode = "contract test {\n" + " uint value1;\n" + " uint value2;\n" + " function f(uint x, uint y) returns (uint w) {\n" + " uint value3 = y;" + " value1 += x;\n" + " value3 *= x;" + " value2 *= value3 + value1;\n" + " return value2 += 7;" + " }\n" + "}\n"; + compileAndRun(sourceCode); + + u256 value1; + u256 value2; + auto f = [&](u256 const& _x, u256 const& _y) -> u256 + { + u256 value3 = _y; + value1 += _x; + value3 *= _x; + value2 *= value3 + value1; + return value2 += 7; + }; + testSolidityAgainstCpp(0, f, u256(0), u256(6)); + testSolidityAgainstCpp(0, f, u256(1), u256(3)); + testSolidityAgainstCpp(0, f, u256(2), u256(25)); + testSolidityAgainstCpp(0, f, u256(3), u256(69)); + testSolidityAgainstCpp(0, f, u256(4), u256(84)); + testSolidityAgainstCpp(0, f, u256(5), u256(2)); + testSolidityAgainstCpp(0, f, u256(6), u256(51)); + testSolidityAgainstCpp(0, f, u256(7), u256(48)); +} + BOOST_AUTO_TEST_CASE(simple_mapping) { char const* sourceCode = "contract test {\n" |