diff options
author | chriseth <chris@ethereum.org> | 2018-10-19 01:02:35 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-19 01:02:35 +0800 |
commit | 4987c12ac3fa16daec6df090a422890ef2823ff4 (patch) | |
tree | fbeeedd368f1ee01ff9ce9f20b6879276dd26c5b | |
parent | 7dffb0f3eecdd1dac75482db2c59207ded7a2dfa (diff) | |
parent | 134f5cb7985965c9fb5756979b4912153f043062 (diff) | |
download | dexon-solidity-4987c12ac3fa16daec6df090a422890ef2823ff4.tar.gz dexon-solidity-4987c12ac3fa16daec6df090a422890ef2823ff4.tar.zst dexon-solidity-4987c12ac3fa16daec6df090a422890ef2823ff4.zip |
Merge pull request #5213 from Mordax/issue-5103
Tests for flipping signs on signed type edge case
-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 7a496e64..133387c8 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -14010,6 +14010,21 @@ BOOST_AUTO_TEST_CASE(test_underscore_in_hex) ABI_CHECK(callContractFunction("f(bool)", false), encodeArgs(u256(0x1234abcd1234))); } +BOOST_AUTO_TEST_CASE(flipping_sign_tests) +{ + char const* sourceCode = R"( + contract test { + function f() public returns (bool){ + int x = -2**255; + assert(-x == x); + return true; + } + } + )"; + compileAndRun(sourceCode); + ABI_CHECK(callContractFunction("f()"), encodeArgs(true)); +} + BOOST_AUTO_TEST_SUITE_END() } |