Added a simple for loop to the expression parser.

Syntax: for (counter = first, last) { body }
Also added a test case.
This commit is contained in:
TomyLobo
2011-11-24 02:32:55 +01:00
parent 7e13b60a51
commit 71287299b5
4 changed files with 104 additions and 7 deletions

View File

@ -95,6 +95,7 @@ public class ExpressionTest {
@Test
public void testFor() throws ExpressionException {
assertEquals(5, simpleEval("a=0; for (i=0; i<5; ++i) { ++a; } a"), 0);
assertEquals(12345, simpleEval("y=0; for (i=1,5) { y *= 10; y += i; } y"), 0);
}
private double simpleEval(String expression) throws ExpressionException {