From 134f5cb7985965c9fb5756979b4912153f043062 Mon Sep 17 00:00:00 2001 From: mordax Date: Sat, 13 Oct 2018 20:22:39 -0400 Subject: Added test for flipping signs on signed type edge case --- test/libsolidity/SolidityEndToEndTest.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'test/libsolidity') 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() } -- cgit v1.2.3