aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/SolidityNameAndTypeResolution.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/libsolidity/SolidityNameAndTypeResolution.cpp')
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp56
1 files changed, 53 insertions, 3 deletions
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index fad1ca61..380978e8 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -1172,7 +1172,7 @@ BOOST_AUTO_TEST_CASE(state_variable_accessors)
BOOST_REQUIRE(function && function->hasDeclaration());
auto returnParams = function->returnParameterTypes();
BOOST_CHECK_EQUAL(returnParams.at(0)->canonicalName(false), "uint256");
- BOOST_CHECK(function->isConstant());
+ BOOST_CHECK(function->stateMutability() == StateMutability::View);
function = retrieveFunctionBySignature(*contract, "map(uint256)");
BOOST_REQUIRE(function && function->hasDeclaration());
@@ -1180,7 +1180,7 @@ BOOST_AUTO_TEST_CASE(state_variable_accessors)
BOOST_CHECK_EQUAL(params.at(0)->canonicalName(false), "uint256");
returnParams = function->returnParameterTypes();
BOOST_CHECK_EQUAL(returnParams.at(0)->canonicalName(false), "bytes4");
- BOOST_CHECK(function->isConstant());
+ BOOST_CHECK(function->stateMutability() == StateMutability::View);
function = retrieveFunctionBySignature(*contract, "multiple_map(uint256,uint256)");
BOOST_REQUIRE(function && function->hasDeclaration());
@@ -1189,7 +1189,7 @@ BOOST_AUTO_TEST_CASE(state_variable_accessors)
BOOST_CHECK_EQUAL(params.at(1)->canonicalName(false), "uint256");
returnParams = function->returnParameterTypes();
BOOST_CHECK_EQUAL(returnParams.at(0)->canonicalName(false), "bytes4");
- BOOST_CHECK(function->isConstant());
+ BOOST_CHECK(function->stateMutability() == StateMutability::View);
}
BOOST_AUTO_TEST_CASE(function_clash_with_state_variable_accessor)
@@ -6657,6 +6657,21 @@ BOOST_AUTO_TEST_CASE(library_function_without_implementation)
CHECK_ERROR(text, TypeError, "Internal library function must be implemented if declared.");
}
+BOOST_AUTO_TEST_CASE(using_for_with_non_library)
+{
+ // This tests a crash that was resolved by making the first error fatal.
+ char const* text = R"(
+ library L {
+ struct S { uint d; }
+ using S for S;
+ function f(S _s) internal {
+ _s.d = 1;
+ }
+ }
+ )";
+ CHECK_ERROR(text, TypeError, "Library name expected.");
+}
+
BOOST_AUTO_TEST_CASE(experimental_pragma)
{
char const* text = R"(
@@ -6694,6 +6709,41 @@ BOOST_AUTO_TEST_CASE(experimental_pragma)
// CHECK_ERROR_ALLOW_MULTI(text, SyntaxError, "Duplicate experimental feature name.");
}
+BOOST_AUTO_TEST_CASE(reject_interface_creation)
+{
+ char const* text = R"(
+ interface I {}
+ contract C {
+ function f() {
+ new I();
+ }
+ }
+ )";
+ CHECK_ERROR(text, TypeError, "Cannot instantiate an interface.");
+}
+
+BOOST_AUTO_TEST_CASE(accept_library_creation)
+{
+ char const* text = R"(
+ library L {}
+ contract C {
+ function f() {
+ new L();
+ }
+ }
+ )";
+ CHECK_SUCCESS(text);
+}
+
+BOOST_AUTO_TEST_CASE(reject_interface_constructors)
+{
+ char const* text = R"(
+ interface I {}
+ contract C is I(2) {}
+ )";
+ CHECK_ERROR(text, TypeError, "Wrong argument count for constructor call: 1 arguments given but expected 0.");
+}
+
BOOST_AUTO_TEST_SUITE_END()
}