aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-09-08 22:48:33 +0800
committerchriseth <c@ethdev.com>2015-09-11 21:21:37 +0800
commit337fde9d11adac85800b405a3fdb4bcd09039ebf (patch)
treea0b63ce5ebcb77f26c724a88ef8ce13fbe852879 /test/libsolidity
parentc5b6d9d2a9fb379e35435726046ce6c551d25c17 (diff)
downloaddexon-solidity-337fde9d11adac85800b405a3fdb4bcd09039ebf.tar.gz
dexon-solidity-337fde9d11adac85800b405a3fdb4bcd09039ebf.tar.zst
dexon-solidity-337fde9d11adac85800b405a3fdb4bcd09039ebf.zip
Parsing and type checking of libraries without inheritance.
Diffstat (limited to 'test/libsolidity')
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp33
-rw-r--r--test/libsolidity/SolidityParser.cpp10
2 files changed, 43 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index 883d7807..adff9499 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -2194,6 +2194,39 @@ BOOST_AUTO_TEST_CASE(string_bytes_conversion)
BOOST_CHECK_NO_THROW(parseTextAndResolveNames(text));
}
+BOOST_AUTO_TEST_CASE(inheriting_from_library)
+{
+ char const* text = R"(
+ library Lib {}
+ contract Test is Lib {}
+ )";
+ BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError);
+}
+
+BOOST_AUTO_TEST_CASE(inheriting_library)
+{
+ char const* text = R"(
+ contract Test {}
+ library Lib is Test {}
+ )";
+ BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError);
+}
+
+BOOST_AUTO_TEST_CASE(library_having_variables)
+{
+ char const* text = R"(
+ library Lib { uint x; }
+ )";
+ BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError);
+}
+
+BOOST_AUTO_TEST_CASE(valid_library)
+{
+ char const* text = R"(
+ library Lib { uint constant x = 9; }
+ )";
+ BOOST_CHECK_NO_THROW(parseTextAndResolveNames(text));
+}
BOOST_AUTO_TEST_CASE(creating_contract_within_the_contract)
{
diff --git a/test/libsolidity/SolidityParser.cpp b/test/libsolidity/SolidityParser.cpp
index 14b9e9e4..1e034863 100644
--- a/test/libsolidity/SolidityParser.cpp
+++ b/test/libsolidity/SolidityParser.cpp
@@ -924,6 +924,16 @@ BOOST_AUTO_TEST_CASE(empty_comment)
BOOST_CHECK_NO_THROW(parseText(text));
}
+BOOST_AUTO_TEST_CASE(library_simple)
+{
+ char const* text = R"(
+ library Lib {
+ function f() { }
+ }
+ )";
+ BOOST_CHECK_NO_THROW(parseText(text));
+}
+
BOOST_AUTO_TEST_SUITE_END()
}