diff options
author | mordax <maya@mordax.io> | 2018-10-14 08:22:39 +0800 |
---|---|---|
committer | mordax <maya@mordax.io> | 2018-10-16 04:08:43 +0800 |
commit | 134f5cb7985965c9fb5756979b4912153f043062 (patch) | |
tree | d5ef6b517a2401404351eb6c0aaa36c2e8a28ef4 | |
parent | 036929aba11268eafb602394af8b212fbe56ae6c (diff) | |
download | dexon-solidity-134f5cb7985965c9fb5756979b4912153f043062.tar.gz dexon-solidity-134f5cb7985965c9fb5756979b4912153f043062.tar.zst dexon-solidity-134f5cb7985965c9fb5756979b4912153f043062.zip |
Added test 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() } |