aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-02-28 23:33:39 +0800
committerGitHub <noreply@github.com>2018-02-28 23:33:39 +0800
commit22d26e059c46274d572403a9528cd24e8d4de867 (patch)
treeef2e58c033f0ccc1e7c3976a7fe2b000e071741c /test
parentac5485a25406ea5274e6c07290d21c3571a71a6e (diff)
parenta566825589a2c0d41e2e136527b98737cffb5701 (diff)
downloaddexon-solidity-22d26e059c46274d572403a9528cd24e8d4de867.tar
dexon-solidity-22d26e059c46274d572403a9528cd24e8d4de867.tar.gz
dexon-solidity-22d26e059c46274d572403a9528cd24e8d4de867.tar.bz2
dexon-solidity-22d26e059c46274d572403a9528cd24e8d4de867.tar.lz
dexon-solidity-22d26e059c46274d572403a9528cd24e8d4de867.tar.xz
dexon-solidity-22d26e059c46274d572403a9528cd24e8d4de867.tar.zst
dexon-solidity-22d26e059c46274d572403a9528cd24e8d4de867.zip
Merge pull request #3613 from ethereum/require-visibility
Issue error if no visibility is specified (on 0.5.0)
Diffstat (limited to 'test')
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp29
-rw-r--r--test/libsolidity/ViewPureChecker.cpp2
2 files changed, 24 insertions, 7 deletions
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index 419e46a7..8c2d853c 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -7974,7 +7974,7 @@ BOOST_AUTO_TEST_CASE(no_address_members_on_contract)
char const* text = R"(
pragma experimental "v0.5.0";
contract C {
- function f() {
+ function f() public {
this.balance;
}
}
@@ -7983,7 +7983,7 @@ BOOST_AUTO_TEST_CASE(no_address_members_on_contract)
text = R"(
pragma experimental "v0.5.0";
contract C {
- function f() {
+ function f() public {
this.transfer;
}
}
@@ -7992,7 +7992,7 @@ BOOST_AUTO_TEST_CASE(no_address_members_on_contract)
text = R"(
pragma experimental "v0.5.0";
contract C {
- function f() {
+ function f() public {
this.send;
}
}
@@ -8001,7 +8001,7 @@ BOOST_AUTO_TEST_CASE(no_address_members_on_contract)
text = R"(
pragma experimental "v0.5.0";
contract C {
- function f() {
+ function f() public {
this.call;
}
}
@@ -8010,7 +8010,7 @@ BOOST_AUTO_TEST_CASE(no_address_members_on_contract)
text = R"(
pragma experimental "v0.5.0";
contract C {
- function f() {
+ function f() public {
this.callcode;
}
}
@@ -8019,7 +8019,7 @@ BOOST_AUTO_TEST_CASE(no_address_members_on_contract)
text = R"(
pragma experimental "v0.5.0";
contract C {
- function f() {
+ function f() public {
this.delegatecall;
}
}
@@ -8103,6 +8103,23 @@ BOOST_AUTO_TEST_CASE(getter_is_memory_type)
}
}
+BOOST_AUTO_TEST_CASE(require_visibility_specifiers)
+{
+ char const* text = R"(
+ contract C {
+ function f() pure { }
+ }
+ )";
+ CHECK_WARNING(text, "No visibility specified. Defaulting to");
+ text = R"(
+ pragma experimental "v0.5.0";
+ contract C {
+ function f() pure { }
+ }
+ )";
+ CHECK_ERROR(text, SyntaxError, "No visibility specified.");
+}
+
BOOST_AUTO_TEST_SUITE_END()
}
diff --git a/test/libsolidity/ViewPureChecker.cpp b/test/libsolidity/ViewPureChecker.cpp
index 3a03c877..2599ca28 100644
--- a/test/libsolidity/ViewPureChecker.cpp
+++ b/test/libsolidity/ViewPureChecker.cpp
@@ -148,7 +148,7 @@ BOOST_AUTO_TEST_CASE(environment_access)
BOOST_AUTO_TEST_CASE(view_error_for_050)
{
CHECK_ERROR(
- "pragma experimental \"v0.5.0\"; contract C { uint x; function f() view { x = 2; } }",
+ "pragma experimental \"v0.5.0\"; contract C { uint x; function f() view public { x = 2; } }",
TypeError,
"Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable."
);