diff options
Merge pull request #66 from chriseth/sol_libraries
Calling libraries.
Diffstat (limited to 'test/libsolidity/SolidityNameAndTypeResolution.cpp')
-rw-r--r-- | test/libsolidity/SolidityNameAndTypeResolution.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index ff91d8e5..5d174367 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -2193,6 +2193,55 @@ 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(call_to_library_function) +{ + char const* text = R"( + library Lib { + uint constant public pimil = 3141592; + function min(uint x, uint y) returns (uint); + } + contract Test { + function f() { + uint t = Lib.min(Lib.pimil(), 7); + } + } + )"; + BOOST_CHECK_NO_THROW(parseTextAndResolveNames(text)); +} BOOST_AUTO_TEST_CASE(creating_contract_within_the_contract) { |