aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2016-08-30 22:09:41 +0800
committerGitHub <noreply@github.com>2016-08-30 22:09:41 +0800
commit79f9a04236ef2d84a7b730a1ca452c8950bfedc4 (patch)
tree59d9b7d32ba461e02bb4caae38c8c081af42732d /test/libsolidity
parent99862d15fe44c6192111bd07b24be646b0f91871 (diff)
parent9a91bd80abc79b82de9e3e7881cccab43e6dde9a (diff)
downloaddexon-solidity-79f9a04236ef2d84a7b730a1ca452c8950bfedc4.tar
dexon-solidity-79f9a04236ef2d84a7b730a1ca452c8950bfedc4.tar.gz
dexon-solidity-79f9a04236ef2d84a7b730a1ca452c8950bfedc4.tar.bz2
dexon-solidity-79f9a04236ef2d84a7b730a1ca452c8950bfedc4.tar.lz
dexon-solidity-79f9a04236ef2d84a7b730a1ca452c8950bfedc4.tar.xz
dexon-solidity-79f9a04236ef2d84a7b730a1ca452c8950bfedc4.tar.zst
dexon-solidity-79f9a04236ef2d84a7b730a1ca452c8950bfedc4.zip
Merge pull request #954 from chriseth/fallbackThrows
Fallback throws
Diffstat (limited to 'test/libsolidity')
-rw-r--r--test/libsolidity/Assembly.cpp2
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp15
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp10
3 files changed, 26 insertions, 1 deletions
diff --git a/test/libsolidity/Assembly.cpp b/test/libsolidity/Assembly.cpp
index 557d496a..81332f4f 100644
--- a/test/libsolidity/Assembly.cpp
+++ b/test/libsolidity/Assembly.cpp
@@ -114,7 +114,7 @@ BOOST_AUTO_TEST_CASE(location_test)
shared_ptr<string const> n = make_shared<string>("source");
AssemblyItems items = compileContract(sourceCode);
vector<SourceLocation> locations =
- vector<SourceLocation>(17, SourceLocation(2, 75, n)) +
+ vector<SourceLocation>(18, SourceLocation(2, 75, n)) +
vector<SourceLocation>(28, SourceLocation(20, 72, n)) +
vector<SourceLocation>{SourceLocation(42, 51, n), SourceLocation(65, 67, n)} +
vector<SourceLocation>(4, SourceLocation(58, 67, n)) +
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index 8a61907a..a370aafa 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -2053,6 +2053,7 @@ BOOST_AUTO_TEST_CASE(contracts_as_addresses)
{
char const* sourceCode = R"(
contract helper {
+ function() { } // can receive ether
}
contract test {
helper h;
@@ -2540,6 +2541,19 @@ BOOST_AUTO_TEST_CASE(inherited_fallback_function)
BOOST_CHECK(callContractFunction("getData()") == encodeArgs(1));
}
+BOOST_AUTO_TEST_CASE(default_fallback_throws)
+{
+ char const* sourceCode = R"(
+ contract A {
+ function f() returns (bool) {
+ return this.call();
+ }
+ }
+ )";
+ compileAndRun(sourceCode);
+ BOOST_CHECK(callContractFunction("f()") == encodeArgs(0));
+}
+
BOOST_AUTO_TEST_CASE(event)
{
char const* sourceCode = R"(
@@ -5943,6 +5957,7 @@ BOOST_AUTO_TEST_CASE(reject_ether_sent_to_library)
function f(address x) returns (bool) {
return x.send(1);
}
+ function () {}
}
)";
compileAndRun(sourceCode, 0, "lib");
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index f0ab07c5..fdd8d7f4 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -1102,6 +1102,16 @@ BOOST_AUTO_TEST_CASE(fallback_function_with_arguments)
BOOST_CHECK(expectError(text) == Error::Type::TypeError);
}
+BOOST_AUTO_TEST_CASE(fallback_function_in_library)
+{
+ char const* text = R"(
+ library C {
+ function() {}
+ }
+ )";
+ BOOST_CHECK(expectError(text) == Error::Type::TypeError);
+}
+
BOOST_AUTO_TEST_CASE(fallback_function_with_return_parameters)
{
char const* text = R"(