Add tests for interfaces

This commit is contained in:
Alex Beregszaszi 2017-02-11 21:17:24 +00:00
parent 4540daaf47
commit cfab70fd89
2 changed files with 107 additions and 0 deletions

View File

@ -5327,6 +5327,104 @@ BOOST_AUTO_TEST_CASE(cyclic_dependency_for_constants)
CHECK_SUCCESS(text);
}
BOOST_AUTO_TEST_CASE(interface)
{
char const* text = R"(
interface I {
}
)";
success(text);
}
BOOST_AUTO_TEST_CASE(interface_constructor)
{
char const* text = R"(
interface I {
function I();
}
)";
success(text);
}
BOOST_AUTO_TEST_CASE(interface_functions)
{
char const* text = R"(
interface I {
function();
function f();
}
)";
success(text);
}
BOOST_AUTO_TEST_CASE(interface_function_bodies)
{
char const* text = R"(
interface I {
function f() {
}
}
)";
CHECK_ERROR(text, TypeError, "Functions in interfaces cannot have an implementation");
}
BOOST_AUTO_TEST_CASE(interface_events)
{
char const* text = R"(
interface I {
event E();
}
)";
success(text);
}
BOOST_AUTO_TEST_CASE(interface_inheritance)
{
char const* text = R"(
interface A {
}
interface I is A {
}
)";
CHECK_ERROR(text, TypeError, "Interfaces cannot inherit");
}
BOOST_AUTO_TEST_CASE(interface_structs)
{
char const* text = R"(
interface I {
struct A {
}
}
)";
CHECK_ERROR(text, TypeError, "Structs cannot be defined in interfaces");
}
BOOST_AUTO_TEST_CASE(interface_variables)
{
char const* text = R"(
interface I {
uint a;
}
)";
CHECK_ERROR(text, TypeError, "Variables cannot be defined in interfaces");
}
BOOST_AUTO_TEST_CASE(using_interface)
{
char const* text = R"(
interface I {
function f();
}
contract C is I {
function f() {
}
}
)";
success(text);
}
BOOST_AUTO_TEST_SUITE_END()
}

View File

@ -1493,6 +1493,15 @@ BOOST_AUTO_TEST_CASE(scientific_notation)
BOOST_CHECK(successParse(text));
}
BOOST_AUTO_TEST_CASE(interface)
{
char const* text = R"(
interface Interface {
function f();
}
)";
BOOST_CHECK(successParse(text));
}
BOOST_AUTO_TEST_SUITE_END()