mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Add more test cases for reference resolving error handling
This commit is contained in:
parent
600e66e605
commit
aef9518039
@ -122,6 +122,20 @@ BOOST_AUTO_TEST_CASE(undeclared_name)
|
|||||||
CHECK_ERROR(text, DeclarationError, "Undeclared identifier.");
|
CHECK_ERROR(text, DeclarationError, "Undeclared identifier.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(undeclared_name_is_not_fatal)
|
||||||
|
{
|
||||||
|
char const* text = R"(
|
||||||
|
contract test {
|
||||||
|
uint256 variable;
|
||||||
|
function f(uint256 arg) public {
|
||||||
|
f(notfound);
|
||||||
|
f(notfound);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
CHECK_ERROR_ALLOW_MULTI(text, DeclarationError, "Undeclared identifier.");
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(reference_to_later_declaration)
|
BOOST_AUTO_TEST_CASE(reference_to_later_declaration)
|
||||||
{
|
{
|
||||||
char const* text = R"(
|
char const* text = R"(
|
||||||
@ -4067,6 +4081,21 @@ BOOST_AUTO_TEST_CASE(modifier_is_not_a_valid_typename)
|
|||||||
CHECK_ERROR(text, TypeError, "Name has to refer to a struct, enum or contract.");
|
CHECK_ERROR(text, TypeError, "Name has to refer to a struct, enum or contract.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(modifier_is_not_a_valid_typename_is_not_fatal)
|
||||||
|
{
|
||||||
|
char const* text = R"(
|
||||||
|
contract test {
|
||||||
|
modifier mod() { _; }
|
||||||
|
|
||||||
|
function f() public {
|
||||||
|
mod g;
|
||||||
|
g = f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
CHECK_ERROR_ALLOW_MULTI(text, TypeError, "Name has to refer to a struct, enum or contract.");
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(function_is_not_a_valid_typename)
|
BOOST_AUTO_TEST_CASE(function_is_not_a_valid_typename)
|
||||||
{
|
{
|
||||||
char const* text = R"(
|
char const* text = R"(
|
||||||
@ -5132,6 +5161,20 @@ BOOST_AUTO_TEST_CASE(payable_internal_function_type)
|
|||||||
CHECK_ERROR(text, TypeError, "Only external function types can be payable.");
|
CHECK_ERROR(text, TypeError, "Only external function types can be payable.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(payable_internal_function_type_is_not_fatal)
|
||||||
|
{
|
||||||
|
char const* text = R"(
|
||||||
|
contract C {
|
||||||
|
function (uint) internal payable returns (uint) x;
|
||||||
|
|
||||||
|
function g() {
|
||||||
|
x = g;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
CHECK_ERROR_ALLOW_MULTI(text, TypeError, "Only external function types can be payable.");
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(call_value_on_non_payable_function_type)
|
BOOST_AUTO_TEST_CASE(call_value_on_non_payable_function_type)
|
||||||
{
|
{
|
||||||
char const* text = R"(
|
char const* text = R"(
|
||||||
@ -6650,6 +6693,28 @@ BOOST_AUTO_TEST_CASE(warn_unspecified_storage)
|
|||||||
CHECK_ERROR(text, TypeError, "Storage location must be specified as either \"memory\" or \"storage\".");
|
CHECK_ERROR(text, TypeError, "Storage location must be specified as either \"memory\" or \"storage\".");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(storage_location_non_array_or_struct_disallowed)
|
||||||
|
{
|
||||||
|
char const* text = R"(
|
||||||
|
contract C {
|
||||||
|
function f(uint storage a) public { }
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
CHECK_ERROR(text, TypeError, "Storage location can only be given for array or struct types.");
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(storage_location_non_array_or_struct_disallowed_is_not_fatal)
|
||||||
|
{
|
||||||
|
char const* text = R"(
|
||||||
|
contract C {
|
||||||
|
function f(uint storage a) public {
|
||||||
|
a = f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
CHECK_ERROR_ALLOW_MULTI(text, TypeError, "Storage location can only be given for array or struct types.");
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(implicit_conversion_disallowed)
|
BOOST_AUTO_TEST_CASE(implicit_conversion_disallowed)
|
||||||
{
|
{
|
||||||
char const* text = R"(
|
char const* text = R"(
|
||||||
|
Loading…
Reference in New Issue
Block a user