aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/SolidityEndToEndTest.cpp
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-09-11 01:40:07 +0800
committerchriseth <c@ethdev.com>2015-09-11 21:21:37 +0800
commit976c380b615f71c9e5b59c9b6bcadefbd79c086f (patch)
tree6ce25599b74529619f4421a9bd3db76eecb80b80 /test/libsolidity/SolidityEndToEndTest.cpp
parenta9edc7b1a601747f96e47fe60a5fc10df489696f (diff)
downloaddexon-solidity-976c380b615f71c9e5b59c9b6bcadefbd79c086f.tar.gz
dexon-solidity-976c380b615f71c9e5b59c9b6bcadefbd79c086f.tar.zst
dexon-solidity-976c380b615f71c9e5b59c9b6bcadefbd79c086f.zip
Possibility to call library functions.
Diffstat (limited to 'test/libsolidity/SolidityEndToEndTest.cpp')
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index aa423330..c56845aa 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -5230,6 +5230,38 @@ BOOST_AUTO_TEST_CASE(storage_string_as_mapping_key_without_variable)
BOOST_CHECK(callContractFunction("f()") == encodeArgs(u256(2)));
}
+BOOST_AUTO_TEST_CASE(library_call)
+{
+ char const* sourceCode = R"(
+ library Lib { function m(uint x, uint y) returns (uint) { return x * y; } }
+ contract Test {
+ function f(uint x) returns (uint) {
+ return Lib.m(x, 9);
+ }
+ }
+ )";
+ compileAndRun(sourceCode, 0, "Lib");
+ compileAndRun(sourceCode, 0, "Test", bytes(), map<string, Address>{{"Lib", m_contractAddress}});
+ BOOST_CHECK(callContractFunction("f(uint256)", u256(33)) == encodeArgs(u256(33) * 9));
+}
+
+BOOST_AUTO_TEST_CASE(library_stray_values)
+{
+ char const* sourceCode = R"(
+ library Lib { function m(uint x, uint y) returns (uint) { return x * y; } }
+ contract Test {
+ function f(uint x) returns (uint) {
+ Lib;
+ Lib.m;
+ return x + 9;
+ }
+ }
+ )";
+ compileAndRun(sourceCode, 0, "Lib");
+ compileAndRun(sourceCode, 0, "Test", bytes(), map<string, Address>{{"Lib", m_contractAddress}});
+ BOOST_CHECK(callContractFunction("f(uint256)", u256(33)) == encodeArgs(u256(42)));
+}
+
BOOST_AUTO_TEST_SUITE_END()
}