aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/SolidityEndToEndTest.cpp
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-05-04 16:16:10 +0800
committerchriseth <c@ethdev.com>2015-05-04 16:54:50 +0800
commit335c67a4e4a8352f5158c55b6ddd805e7045547b (patch)
tree210333b3d381ed38c063f3fff862516d629bc136 /libsolidity/SolidityEndToEndTest.cpp
parent1d4b27322e23e5545e8a9d84809aa3c0766f37dc (diff)
downloaddexon-solidity-335c67a4e4a8352f5158c55b6ddd805e7045547b.tar
dexon-solidity-335c67a4e4a8352f5158c55b6ddd805e7045547b.tar.gz
dexon-solidity-335c67a4e4a8352f5158c55b6ddd805e7045547b.tar.bz2
dexon-solidity-335c67a4e4a8352f5158c55b6ddd805e7045547b.tar.lz
dexon-solidity-335c67a4e4a8352f5158c55b6ddd805e7045547b.tar.xz
dexon-solidity-335c67a4e4a8352f5158c55b6ddd805e7045547b.tar.zst
dexon-solidity-335c67a4e4a8352f5158c55b6ddd805e7045547b.zip
Fix for broken continue in for loop.
Fixes #1789.
Diffstat (limited to 'libsolidity/SolidityEndToEndTest.cpp')
-rw-r--r--libsolidity/SolidityEndToEndTest.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/libsolidity/SolidityEndToEndTest.cpp b/libsolidity/SolidityEndToEndTest.cpp
index 24e5f7b4..f168ad45 100644
--- a/libsolidity/SolidityEndToEndTest.cpp
+++ b/libsolidity/SolidityEndToEndTest.cpp
@@ -300,6 +300,52 @@ BOOST_AUTO_TEST_CASE(for_loop_simple_init_expr)
testSolidityAgainstCppOnRange("f(uint256)", for_loop_simple_init_expr_cpp, 0, 5);
}
+BOOST_AUTO_TEST_CASE(for_loop_break_continue)
+{
+ char const* sourceCode = R"(
+ contract test {
+ function f(uint n) returns (uint r)
+ {
+ uint i = 1;
+ uint k = 0;
+ for (i *= 5; k < n; i *= 7)
+ {
+ k++;
+ i += 4;
+ if (n % 3 == 0)
+ break;
+ i += 9;
+ if (n % 2 == 0)
+ continue;
+ i += 19;
+ }
+ return i;
+ }
+ }
+ )";
+ compileAndRun(sourceCode);
+
+ auto breakContinue = [](u256 const& n) -> u256
+ {
+ u256 i = 1;
+ u256 k = 0;
+ for (i *= 5; k < n; i *= 7)
+ {
+ k++;
+ i += 4;
+ if (n % 3 == 0)
+ break;
+ i += 9;
+ if (n % 2 == 0)
+ continue;
+ i += 19;
+ }
+ return i;
+ };
+
+ testSolidityAgainstCppOnRange("f(uint256)", breakContinue, 0, 10);
+}
+
BOOST_AUTO_TEST_CASE(calling_other_functions)
{
char const* sourceCode = "contract collatz {\n"