From b25f0c52ac01857a82dda20ec2b646c7ae90cd7d Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Sat, 12 Aug 2017 00:45:37 +0100 Subject: Reject the creation of interface with the new statement --- test/libsolidity/SolidityNameAndTypeResolution.cpp | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'test') diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index e349bf83..a4fc9c98 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -6709,6 +6709,32 @@ 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_SUITE_END() } -- cgit v1.2.3