diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2017-02-12 05:17:24 +0800 |
---|---|---|
committer | Alex Beregszaszi <alex@rtfs.hu> | 2017-03-18 01:06:49 +0800 |
commit | cfab70fd89e98f9301838682b28b9e400e1b2632 (patch) | |
tree | a184093591d0de59f71afb0aba12dab8ce6b23f4 | |
parent | 4540daaf475490f0ea85d8cc0ec54c261b3eb5d6 (diff) | |
download | dexon-solidity-cfab70fd89e98f9301838682b28b9e400e1b2632.tar dexon-solidity-cfab70fd89e98f9301838682b28b9e400e1b2632.tar.gz dexon-solidity-cfab70fd89e98f9301838682b28b9e400e1b2632.tar.bz2 dexon-solidity-cfab70fd89e98f9301838682b28b9e400e1b2632.tar.lz dexon-solidity-cfab70fd89e98f9301838682b28b9e400e1b2632.tar.xz dexon-solidity-cfab70fd89e98f9301838682b28b9e400e1b2632.tar.zst dexon-solidity-cfab70fd89e98f9301838682b28b9e400e1b2632.zip |
Add tests for interfaces
-rw-r--r-- | test/libsolidity/SolidityNameAndTypeResolution.cpp | 98 | ||||
-rw-r--r-- | test/libsolidity/SolidityParser.cpp | 9 |
2 files changed, 107 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index fa310434..0861dded 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -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() } diff --git a/test/libsolidity/SolidityParser.cpp b/test/libsolidity/SolidityParser.cpp index ffb4b6f2..6e33aba5 100644 --- a/test/libsolidity/SolidityParser.cpp +++ b/test/libsolidity/SolidityParser.cpp @@ -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() |