aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity
diff options
context:
space:
mode:
Diffstat (limited to 'test/libsolidity')
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp19
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp14
2 files changed, 32 insertions, 1 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index 4075a016..4924b55d 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -8462,6 +8462,25 @@ BOOST_AUTO_TEST_CASE(function_array_cross_calls)
BOOST_CHECK(callContractFunction("test()") == encodeArgs(u256(5), u256(6), u256(7)));
}
+BOOST_AUTO_TEST_CASE(external_function_to_address)
+{
+ char const* sourceCode = R"(
+ contract C {
+ function f() returns (bool) {
+ return address(this.f) == address(this);
+ }
+ function g(function() external cb) returns (address) {
+ return address(cb);
+ }
+ }
+ )";
+
+ compileAndRun(sourceCode, 0, "C");
+ BOOST_CHECK(callContractFunction("f()") == encodeArgs(true));
+ BOOST_CHECK(callContractFunction("g(function)", fromHex("00000000000000000000000000000000000004226121ff00000000000000000")) == encodeArgs(u160(0x42)));
+}
+
+
BOOST_AUTO_TEST_CASE(copy_internal_function_array_to_storage)
{
char const* sourceCode = R"(
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index 1aca7ab9..587f1075 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -4729,7 +4729,7 @@ BOOST_AUTO_TEST_CASE(external_function_type_to_address)
{
char const* text = R"(
contract C {
- function f() return (address) {
+ function f() returns (address) {
return address(this.f);
}
}
@@ -4737,6 +4737,18 @@ BOOST_AUTO_TEST_CASE(external_function_type_to_address)
CHECK_SUCCESS(text);
}
+BOOST_AUTO_TEST_CASE(internal_function_type_to_address)
+{
+ char const* text = R"(
+ contract C {
+ function f() returns (address) {
+ return address(f);
+ }
+ }
+ )";
+ CHECK_ERROR(text, TypeError, "");
+}
+
BOOST_AUTO_TEST_CASE(invalid_fixed_point_literal)
{
char const* text = R"(