mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #3364 from ethereum/revertWithReason
Revert with reason
This commit is contained in:
@@ -5987,14 +5987,30 @@ BOOST_AUTO_TEST_CASE(bare_revert)
|
||||
}
|
||||
}
|
||||
)";
|
||||
CHECK_WARNING(text, "Statement has no effect.");
|
||||
CHECK_ERROR(text, TypeError, "No matching declaration found");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(revert_with_reason)
|
||||
{
|
||||
char const* text = R"(
|
||||
contract C {
|
||||
function f(uint x) pure public {
|
||||
if (x > 7)
|
||||
revert("abc");
|
||||
else
|
||||
revert();
|
||||
}
|
||||
}
|
||||
)";
|
||||
CHECK_SUCCESS_NO_WARNINGS(text);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(bare_others)
|
||||
{
|
||||
CHECK_WARNING("contract C { function f() pure public { selfdestruct; } }", "Statement has no effect.");
|
||||
CHECK_WARNING("contract C { function f() pure public { assert; } }", "Statement has no effect.");
|
||||
CHECK_WARNING("contract C { function f() pure public { require; } }", "Statement has no effect.");
|
||||
// This is different because it does have overloads.
|
||||
CHECK_ERROR("contract C { function f() pure public { require; } }", TypeError, "No matching declaration found after variable lookup.");
|
||||
CHECK_WARNING("contract C { function f() pure public { suicide; } }", "Statement has no effect.");
|
||||
}
|
||||
|
||||
@@ -6493,7 +6509,7 @@ BOOST_AUTO_TEST_CASE(does_not_error_transfer_regular_function)
|
||||
CHECK_SUCCESS_NO_WARNINGS(text);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(returndatacopy_as_variable)
|
||||
BOOST_AUTO_TEST_CASE(returndatasize_as_variable)
|
||||
{
|
||||
char const* text = R"(
|
||||
contract c { function f() public { uint returndatasize; assembly { returndatasize }}}
|
||||
|
||||
Reference in New Issue
Block a user