aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/SolidityEndToEndTest.cpp
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-07-27 17:52:42 +0800
committerchriseth <chris@ethereum.org>2017-07-27 19:45:39 +0800
commit7c7c2baa82ec2fa0535381c2ea3418b8623a9062 (patch)
tree6a5bea3334a5e4c426beea7365312b314ab1f36f /test/libsolidity/SolidityEndToEndTest.cpp
parent07e0a7e090111dd49e0bb6af96a4036f1bd186ac (diff)
downloaddexon-solidity-7c7c2baa82ec2fa0535381c2ea3418b8623a9062.tar.gz
dexon-solidity-7c7c2baa82ec2fa0535381c2ea3418b8623a9062.tar.zst
dexon-solidity-7c7c2baa82ec2fa0535381c2ea3418b8623a9062.zip
Re-allow multiple modifiers per function.
Diffstat (limited to 'test/libsolidity/SolidityEndToEndTest.cpp')
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index 94d3e168..5bcde441 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -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"(