Merge pull request #5213 from Mordax/issue-5103

Tests for flipping signs on signed type edge case
This commit is contained in:
chriseth 2018-10-18 19:02:35 +02:00 committed by GitHub
commit 4987c12ac3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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()
}