aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2016-08-17 17:28:02 +0800
committerGitHub <noreply@github.com>2016-08-17 17:28:02 +0800
commite7683f4722791d39ca63913ec98feb1ea9f5164d (patch)
treea94bb062fc66a955005d7eafa7160ee3ad35dd63 /test
parente4578982c6e1a39ca3457ab1844be37b500dedda (diff)
parent15b85e2ea809ab09ec78955e80666b64b80ddbf1 (diff)
downloaddexon-solidity-e7683f4722791d39ca63913ec98feb1ea9f5164d.tar.gz
dexon-solidity-e7683f4722791d39ca63913ec98feb1ea9f5164d.tar.zst
dexon-solidity-e7683f4722791d39ca63913ec98feb1ea9f5164d.zip
Merge pull request #836 from chriseth/unusedunderscore
BREAKING: Require modifiers to contain "_".
Diffstat (limited to 'test')
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp4
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp30
2 files changed, 22 insertions, 12 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index 3920d948..a1ab7700 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -2410,7 +2410,7 @@ BOOST_AUTO_TEST_CASE(function_modifier_overriding)
modifier mod { _ }
}
contract C is A {
- modifier mod { }
+ modifier mod { if (false) _ }
}
)";
compileAndRun(sourceCode);
@@ -2427,7 +2427,7 @@ BOOST_AUTO_TEST_CASE(function_modifier_calling_functions_in_creation_context)
function f2() { data |= 0x20; }
function f3() { }
modifier mod1 { f2(); _ }
- modifier mod2 { f3(); }
+ modifier mod2 { f3(); if (false) _ }
function getData() returns (uint r) { return data; }
}
contract C is A {
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index 7e81bd7e..e9da390c 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -901,8 +901,8 @@ BOOST_AUTO_TEST_CASE(function_modifier_invocation_local_variables)
BOOST_AUTO_TEST_CASE(legal_modifier_override)
{
char const* text = R"(
- contract A { modifier mod(uint a) {} }
- contract B is A { modifier mod(uint a) {} }
+ contract A { modifier mod(uint a) { _ } }
+ contract B is A { modifier mod(uint a) { _ } }
)";
BOOST_CHECK(success(text));
}
@@ -910,8 +910,8 @@ BOOST_AUTO_TEST_CASE(legal_modifier_override)
BOOST_AUTO_TEST_CASE(illegal_modifier_override)
{
char const* text = R"(
- contract A { modifier mod(uint a) {} }
- contract B is A { modifier mod(uint8 a) {} }
+ contract A { modifier mod(uint a) { _ } }
+ contract B is A { modifier mod(uint8 a) { _ } }
)";
BOOST_CHECK(expectError(text) == Error::Type::TypeError);
}
@@ -919,8 +919,8 @@ BOOST_AUTO_TEST_CASE(illegal_modifier_override)
BOOST_AUTO_TEST_CASE(modifier_overrides_function)
{
char const* text = R"(
- contract A { modifier mod(uint a) {} }
- contract B is A { function mod(uint a) {} }
+ contract A { modifier mod(uint a) { _ } }
+ contract B is A { function mod(uint a) { } }
)";
BOOST_CHECK(expectError(text) == Error::Type::TypeError);
}
@@ -928,8 +928,8 @@ BOOST_AUTO_TEST_CASE(modifier_overrides_function)
BOOST_AUTO_TEST_CASE(function_overrides_modifier)
{
char const* text = R"(
- contract A { function mod(uint a) {} }
- contract B is A { modifier mod(uint a) {} }
+ contract A { function mod(uint a) { } }
+ contract B is A { modifier mod(uint a) { _ } }
)";
BOOST_CHECK(expectError(text) == Error::Type::TypeError);
}
@@ -938,8 +938,8 @@ BOOST_AUTO_TEST_CASE(modifier_returns_value)
{
char const* text = R"(
contract A {
- function f(uint a) mod(2) returns (uint r) {}
- modifier mod(uint a) { return 7; }
+ function f(uint a) mod(2) returns (uint r) { }
+ modifier mod(uint a) { _ return 7; }
}
)";
BOOST_CHECK(expectError(text) == Error::Type::TypeError);
@@ -3823,6 +3823,16 @@ BOOST_AUTO_TEST_CASE(unused_return_value_delegatecall)
BOOST_CHECK(expectError(text, true) == Error::Type::Warning);
}
+BOOST_AUTO_TEST_CASE(modifier_without_underscore)
+{
+ char const* text = R"(
+ contract test {
+ modifier m() {}
+ }
+ )";
+ BOOST_CHECK(expectError(text, true) == Error::Type::SyntaxError);
+}
+
BOOST_AUTO_TEST_SUITE_END()
}