aboutsummaryrefslogtreecommitdiffstats
path: root/solidityEndToEndTest.cpp
diff options
context:
space:
mode:
authorLefteris Karapetsas <lefteris@refu.co>2014-12-16 23:52:47 +0800
committerLefteris Karapetsas <lefteris@refu.co>2014-12-17 07:03:30 +0800
commit9f5f39300dd601b1f81b7b7258ad0a87b70cd26d (patch)
tree5160e1426f295826b7ae39956e53d74e09d39849 /solidityEndToEndTest.cpp
parent28fc8815470c1e64adf8b4238d3b40bd6f7f6a1d (diff)
downloaddexon-solidity-9f5f39300dd601b1f81b7b7258ad0a87b70cd26d.tar.gz
dexon-solidity-9f5f39300dd601b1f81b7b7258ad0a87b70cd26d.tar.zst
dexon-solidity-9f5f39300dd601b1f81b7b7258ad0a87b70cd26d.zip
Solidity ForStatement Compiler part
- Work in progress
Diffstat (limited to 'solidityEndToEndTest.cpp')
-rw-r--r--solidityEndToEndTest.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/solidityEndToEndTest.cpp b/solidityEndToEndTest.cpp
index b6f63aa7..32de9af4 100644
--- a/solidityEndToEndTest.cpp
+++ b/solidityEndToEndTest.cpp
@@ -176,6 +176,28 @@ BOOST_AUTO_TEST_CASE(nested_loops)
testSolidityAgainstCppOnRange(0, nested_loops_cpp, 0, 12);
}
+BOOST_AUTO_TEST_CASE(for_loop)
+{
+ char const* sourceCode = "contract test {\n"
+ " function f(uint n) returns(uint nfac) {\n"
+ " nfac = 1;\n"
+ " for (var i = 2; i <= n; i++)\n"
+ " nfac *= 1;\n"
+ " }\n"
+ "}\n";
+ compileAndRun(sourceCode);
+
+ auto for_loop_cpp = [](u256 const& n) -> u256
+ {
+ u256 nfac = 1;
+ for (auto i = 2; i <= n; i++)
+ nfac *= i;
+ return nfac;
+ };
+
+ testSolidityAgainstCppOnRange(0, for_loop_cpp, 0, 5);
+}
+
BOOST_AUTO_TEST_CASE(calling_other_functions)
{
// note that the index of a function is its index in the sorted sequence of functions