mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Re-allow multiple modifiers per function.
This commit is contained in:
@@ -2696,6 +2696,34 @@ BOOST_AUTO_TEST_CASE(function_modifier_for_constructor)
|
||||
BOOST_CHECK(callContractFunction("getData()") == encodeArgs(4 | 2));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(function_modifier_multiple_times)
|
||||
{
|
||||
char const* sourceCode = R"(
|
||||
contract C {
|
||||
uint public a;
|
||||
modifier mod(uint x) { a += x; _; }
|
||||
function f(uint x) mod(2) mod(5) mod(x) returns(uint) { return a; }
|
||||
}
|
||||
)";
|
||||
compileAndRun(sourceCode);
|
||||
BOOST_CHECK(callContractFunction("f(uint256)", u256(3)) == encodeArgs(2 + 5 + 3));
|
||||
BOOST_CHECK(callContractFunction("a()") == encodeArgs(2 + 5 + 3));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(function_modifier_multiple_times_local_vars)
|
||||
{
|
||||
char const* sourceCode = R"(
|
||||
contract C {
|
||||
uint public a;
|
||||
modifier mod(uint x) { uint b = x; a += b; _; a -= b; assert(b == x); }
|
||||
function f(uint x) mod(2) mod(5) mod(x) returns(uint) { return a; }
|
||||
}
|
||||
)";
|
||||
compileAndRun(sourceCode);
|
||||
BOOST_CHECK(callContractFunction("f(uint256)", u256(3)) == encodeArgs(2 + 5 + 3));
|
||||
BOOST_CHECK(callContractFunction("a()") == encodeArgs(0));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(crazy_elementary_typenames_on_stack)
|
||||
{
|
||||
char const* sourceCode = R"(
|
||||
|
||||
@@ -1115,7 +1115,7 @@ BOOST_AUTO_TEST_CASE(function_modifier_double_invocation)
|
||||
modifier mod(uint a) { if (a > 0) _; }
|
||||
}
|
||||
)";
|
||||
CHECK_ERROR(text, DeclarationError, "Modifier already used for this function");
|
||||
success(text);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(base_constructor_double_invocation)
|
||||
|
||||
Reference in New Issue
Block a user