aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorFederico Bond <federicobond@gmail.com>2018-01-04 22:45:44 +0800
committerFederico Bond <federicobond@gmail.com>2018-02-03 01:09:32 +0800
commitaef95180392fcff5f339655754535a34c8564599 (patch)
treea2d6c9bc2034ee70c5a881820201d7e04ac2d174 /test
parent600e66e6057b1d6992affaf6fa646ce865d17b73 (diff)
downloaddexon-solidity-aef95180392fcff5f339655754535a34c8564599.tar
dexon-solidity-aef95180392fcff5f339655754535a34c8564599.tar.gz
dexon-solidity-aef95180392fcff5f339655754535a34c8564599.tar.bz2
dexon-solidity-aef95180392fcff5f339655754535a34c8564599.tar.lz
dexon-solidity-aef95180392fcff5f339655754535a34c8564599.tar.xz
dexon-solidity-aef95180392fcff5f339655754535a34c8564599.tar.zst
dexon-solidity-aef95180392fcff5f339655754535a34c8564599.zip
Add more test cases for reference resolving error handling
Diffstat (limited to 'test')
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp65
1 files changed, 65 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index 65f5a647..86424696 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -122,6 +122,20 @@ BOOST_AUTO_TEST_CASE(undeclared_name)
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)
{
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.");
}
+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)
{
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.");
}
+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)
{
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\".");
}
+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)
{
char const* text = R"(